Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const SearchExamplesApp = ({
});
};

const doSearchSourceSearch = async () => {
const doSearchSourceSearch = async (otherBucket: boolean) => {
if (!indexPattern) return;

const query = data.query.queryString.getQuery();
Expand All @@ -221,7 +221,7 @@ export const SearchExamplesApp = ({
aggDef.push({
type: 'terms',
schema: 'split',
params: { field: selectedBucketField.name, size: 2, otherBucket: true },
params: { field: selectedBucketField.name, size: 2, otherBucket },
});
}
if (selectedNumericField) {
Expand Down Expand Up @@ -280,8 +280,8 @@ export const SearchExamplesApp = ({
}
};

const onSearchSourceClickHandler = () => {
doSearchSourceSearch();
const onSearchSourceClickHandler = (withOtherBucket: boolean) => {
doSearchSourceSearch(withOtherBucket);
};

const reqTabs = [
Expand Down Expand Up @@ -367,6 +367,7 @@ export const SearchExamplesApp = ({
setIndexPattern(newIndexPattern);
}}
isClearable={false}
data-test-subj="indexPatternSelector"
/>
</EuiFlexItem>
<EuiFlexItem>
Expand Down Expand Up @@ -449,7 +450,7 @@ export const SearchExamplesApp = ({
</EuiText>
<EuiButtonEmpty
size="xs"
onClick={onSearchSourceClickHandler}
onClick={() => onSearchSourceClickHandler(true)}
iconType="play"
data-test-subj="searchSourceWithOther"
>
Expand All @@ -464,6 +465,23 @@ export const SearchExamplesApp = ({
defaultMessage="Bucket and metrics aggregations with other bucket."
/>
</EuiText>
<EuiButtonEmpty
size="xs"
onClick={() => onSearchSourceClickHandler(false)}
iconType="play"
data-test-subj="searchSourceWithoutOther"
>
<FormattedMessage
id="searchExamples.searchSource.buttonText"
defaultMessage="Request from high-level client (data.search.searchSource)"
/>
</EuiButtonEmpty>
<EuiText size="xs" color="subdued" className="searchExampleStepDsc">
<FormattedMessage
id="searchExamples.buttonText"
defaultMessage="Bucket and metrics aggregations without other bucket."
/>
</EuiText>
</EuiText>
<EuiSpacer />
<EuiTitle size="s">
Expand Down
37 changes: 28 additions & 9 deletions x-pack/test/examples/search_examples/search_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'timePicker']);
const retry = getService('retry');
const comboBox = getService('comboBox');

describe.skip('Search session example', () => {
describe('Search session example', () => {
const appId = 'searchExamples';

before(async function () {
await PageObjects.common.navigateToApp(appId, { insertTimestamp: false });
await comboBox.set('indexPatternSelector', 'logstash-*');
await comboBox.set('searchBucketField', 'geo.src');
await comboBox.set('searchMetricField', 'memory');
await PageObjects.timePicker.setAbsoluteRange(
'Mar 1, 2015 @ 00:00:00.000',
'Nov 1, 2015 @ 00:00:00.000'
);
});

it('should have an other bucket', async () => {
await PageObjects.timePicker.setAbsoluteRange(
'Jan 1, 2014 @ 00:00:00.000',
'Jan 1, 2016 @ 00:00:00.000'
);
await testSubjects.click('searchSourceWithOther');
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
await retry.waitFor('get code block', async () => {
const visibleText = await codeBlock.getVisibleText();
const parsedResponse = JSON.parse(visibleText);
const buckets = parsedResponse.aggregations[1].buckets;
return (
buckets.length === 3 && buckets[2].key === '__other__' && buckets[2].doc_count === 9039
);
});
});

await retry.waitFor('has other bucket', async () => {
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
it('should not have an other bucket', async () => {
await testSubjects.click('searchSourceWithoutOther');
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
await retry.waitFor('get code block', async () => {
const visibleText = await codeBlock.getVisibleText();
return visibleText.indexOf('__other__') > -1;
const parsedResponse = JSON.parse(visibleText);
const buckets = parsedResponse.aggregations[1].buckets;
return buckets.length === 2;
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common']);
const toasts = getService('toasts');
const retry = getService('retry');
const comboBox = getService('comboBox');

async function getExecutedAt() {
const toast = await toasts.getToastElement(1);
Expand All @@ -26,11 +27,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
return text;
}

describe.skip('Search session client side cache', () => {
describe('Search session client side cache', () => {
const appId = 'searchExamples';

before(async function () {
await PageObjects.common.navigateToApp(appId, { insertTimestamp: false });
await comboBox.set('indexPatternSelector', 'logstash-*');
await comboBox.set('searchBucketField', 'extension.raw');
await comboBox.set('searchMetricField', 'phpmemory');
});

it('should cache responses by search session id', async () => {
Expand Down