diff --git a/examples/search_examples/public/components/app.tsx b/examples/search_examples/public/components/app.tsx index 33ad8bbfe3d..1e83fb34f9e 100644 --- a/examples/search_examples/public/components/app.tsx +++ b/examples/search_examples/public/components/app.tsx @@ -40,6 +40,7 @@ import { EuiCode, EuiComboBox, EuiFormLabel, + EuiButton, } from '@elastic/eui'; import { CoreStart } from '../../../../src/core/public'; @@ -60,6 +61,7 @@ import { isCompleteResponse, isErrorResponse, } from '../../../../src/plugins/data/public'; +import { buildFilter, FILTERS, FilterStateStore } from '../../../../src/plugins/data/common'; interface SearchExamplesAppDeps { basename: string; @@ -271,6 +273,7 @@ export const SearchExamplesApp = ({ showSearchBar={true} useDefaultBehaviors={true} indexPatterns={indexPattern ? [indexPattern] : undefined} + onFiltersUpdated={() => {}} /> @@ -345,6 +348,25 @@ export const SearchExamplesApp = ({ + +

+ Add or remove filter from application +

+
+ + { + if (!indexPattern) return; + const filterType = FILTERS.PHRASE; + const newFilter = buildFilter(indexPattern, indexPattern.getFieldByName('extension')!, filterType, true, false, 'jpg', null, FilterStateStore.APP_STATE); + data.query.filterManager.addFilters(newFilter) + }}>Add FILTER + + { + const filters = data.query.filterManager.getAppFilters(); + if (filters.length) data.query.filterManager.removeFilter(filters[0]) + }}>Remove FILTER + +

Searching Elasticsearch using data.search