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
This commit is contained in:
Lukas Olson 2017-07-11 10:46:55 -07:00 committed by GitHub
parent 9ab0fc90c3
commit 055080521c
5 changed files with 18 additions and 5 deletions

View file

@ -73,6 +73,7 @@ mentioned use "_default_".
`timepicker:refreshIntervalDefaults`:: The time filter's default refresh interval.
`dashboard:defaultDarkTheme`:: Set this property to `true` to make new dashboards use the dark theme by default.
`filters:pinnedByDefault`:: Set this property to `true` to make filters have a global state by default.
`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.
`notifications:banner`:: You can specify a custom banner to display temporary notices to all users. This field supports
Markdown.
`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.

View file

@ -10,7 +10,12 @@ export function registerValueSuggestions(server) {
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
const include = query ? `.*${query}.*` : undefined;
const body = getBody({ field, include });
const body = getBody({
field,
include,
shard_size: 10,
size: 10
});
return callWithRequest(req, 'search', { index, body })
.then((res) => {

View file

@ -259,6 +259,11 @@ export function getUiSettingDefaults() {
value: false,
description: 'Whether the filters should have a global state (be pinned) by default'
},
'filterEditor:suggestValues': {
value: false,
description: '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.'
},
'notifications:banner': {
type: 'markdown',
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>.',

View file

@ -1,7 +1,9 @@
import _ from 'lodash';
import chrome from 'ui/chrome';
export function filterParamsPhraseController($http, $scope) {
export function filterParamsPhraseController($http, $scope, config) {
const shouldSuggestValues = this.shouldSuggestValues = config.get('filterEditor:suggestValues');
this.compactUnion = _.flow(_.union, _.compact);
this.getValueSuggestions = _.memoize(getValueSuggestions, getFieldQueryHash);
@ -14,7 +16,7 @@ export function filterParamsPhraseController($http, $scope) {
this.refreshValueSuggestions();
function getValueSuggestions(field, query) {
if (!_.get(field, 'aggregatable') || field.type !== 'string') {
if (!shouldSuggestValues || !_.get(field, 'aggregatable') || field.type !== 'string') {
return Promise.resolve([]);
}

View file

@ -1,5 +1,5 @@
<ui-select
ng-if="field.aggregatable && field.type === 'string'"
ng-if="filterParamsPhraseEditor.shouldSuggestValues && field.aggregatable && field.type === 'string'"
ng-model="params.phrase"
ui-select-focus-on="focus-params"
>
@ -22,7 +22,7 @@
</ui-select>
<filter-params-input-type
ng-if="!(field.aggregatable && field.type === 'string')"
ng-if="!(filterParamsPhraseEditor.shouldSuggestValues && field.aggregatable && field.type === 'string')"
placeholder="Value..."
type="field.type"
value="params.phrase"