Skip to content

Commit d2675d4

Browse files
committed
Make filter editor suggestions opt-in (#12710)
* Add shard_size to the suggestions terms agg request * Make filter editor suggestions opt-in * Add size parameter
1 parent dc19cd1 commit d2675d4

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

docs/management/advanced-options.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ mentioned use "_default_".
7373
`timepicker:refreshIntervalDefaults`:: The time filter's default refresh interval.
7474
`dashboard:defaultDarkTheme`:: Set this property to `true` to make new dashboards use the dark theme by default.
7575
`filters:pinnedByDefault`:: Set this property to `true` to make filters have a global state by default.
76+
`filterEditor:suggestValues`:: Set this property to `true` to have the filter editor suggest values for fields, instead of just providing a text input. This may result in heavy queries to Elasticsearch.
7677
`notifications:banner`:: You can specify a custom banner to display temporary notices to all users. This field supports
7778
Markdown.
7879
`notifications:lifetime:banner`:: Specifies the duration in milliseconds for banner notification displays. The default value is 3000000. Set this field to `Infinity` to disable banner notifications.

src/core_plugins/kibana/server/routes/api/suggestions/register_value_suggestions.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ export function registerValueSuggestions(server) {
1010

1111
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
1212
const include = query ? `.*${query}.*` : undefined;
13-
const body = getBody({ field, include });
13+
const body = getBody({
14+
field,
15+
include,
16+
shard_size: 10,
17+
size: 10
18+
});
1419

1520
return callWithRequest(req, 'search', { index, body })
1621
.then((res) => {

src/core_plugins/kibana/ui_setting_defaults.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ export function getUiSettingDefaults() {
254254
value: false,
255255
description: 'Whether the filters should have a global state (be pinned) by default'
256256
},
257+
'filterEditor:suggestValues': {
258+
value: false,
259+
description: 'Set this property to `true` to have the filter editor suggest values for fields, ' +
260+
'instead of just providing a text input. This may result in heavy queries to Elasticsearch.'
261+
},
257262
'notifications:banner': {
258263
type: 'markdown',
259264
description: 'A custom banner intended for temporary notices to all users. <a href="https://help.github.com/articles/basic-writing-and-formatting-syntax/" target="_blank">Markdown supported</a>.',

src/ui/public/filter_editor/params_editor/filter_params_phrase_controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import _ from 'lodash';
22
import chrome from 'ui/chrome';
33

4-
export function filterParamsPhraseController($http, $scope) {
4+
export function filterParamsPhraseController($http, $scope, config) {
5+
const shouldSuggestValues = this.shouldSuggestValues = config.get('filterEditor:suggestValues');
6+
57
this.compactUnion = _.flow(_.union, _.compact);
68

79
this.getValueSuggestions = _.memoize(getValueSuggestions, getFieldQueryHash);
@@ -14,7 +16,7 @@ export function filterParamsPhraseController($http, $scope) {
1416
this.refreshValueSuggestions();
1517

1618
function getValueSuggestions(field, query) {
17-
if (!_.get(field, 'aggregatable') || field.type !== 'string') {
19+
if (!shouldSuggestValues || !_.get(field, 'aggregatable') || field.type !== 'string') {
1820
return Promise.resolve([]);
1921
}
2022

src/ui/public/filter_editor/params_editor/filter_params_phrase_editor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ui-select
2-
ng-if="field.aggregatable && field.type === 'string'"
2+
ng-if="filterParamsPhraseEditor.shouldSuggestValues && field.aggregatable && field.type === 'string'"
33
ng-model="params.phrase"
44
ui-select-focus-on="focus-params"
55
>
@@ -22,7 +22,7 @@
2222
</ui-select>
2323

2424
<filter-params-input-type
25-
ng-if="!(field.aggregatable && field.type === 'string')"
25+
ng-if="!(filterParamsPhraseEditor.shouldSuggestValues && field.aggregatable && field.type === 'string')"
2626
placeholder="Value..."
2727
type="field.type"
2828
value="params.phrase"

0 commit comments

Comments
 (0)