diff --git a/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx b/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx index 9ef5f546c0be0..426c21c99ccdb 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx +++ b/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx @@ -18,6 +18,7 @@ */ import { Component } from 'react'; +import { debounce } from 'lodash'; import { Field, IndexPattern } from '../../../index_patterns'; import { withKibana, @@ -65,7 +66,7 @@ export class PhraseSuggestorUI extends Component this.updateSuggestions(`${value}`); }; - protected async updateSuggestions(value: string = '') { + protected updateSuggestions = debounce(async (value: string = '') => { const { indexPattern, field } = this.props as PhraseSuggestorProps; if (!field || !this.isSuggestingValues()) { return; @@ -73,7 +74,7 @@ export class PhraseSuggestorUI extends Component this.setState({ isLoading: true }); const suggestions = await this.services.data.getSuggestions(indexPattern.title, field, value); this.setState({ suggestions, isLoading: false }); - } + }, 500); } export const PhraseSuggestor = withKibana(PhraseSuggestorUI);