[8.8] [Unified search] Fixes the bar suggestions method selection (#156329) (#156478)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Unified search] Fixes the bar suggestions method selection
(#156329)](https://github.com/elastic/kibana/pull/156329)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2023-05-03T08:16:55Z","message":"[Unified
search] Fixes the bar suggestions method selection (#156329)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155801\r\n\r\nFixes the bug
described
here\r\nhttps://github.com/elastic/kibana/issues/155801\r\n\r\nThe bug
was introduced
by\r\nhttps://github.com/elastic/kibana/pull/154522/files\r\n\r\nIf the
filtersForSuggestions prop is there, we want to default to\r\nterms_agg,
otherwise we want to keep it as undefined to use the
advanced\r\nsettings
method.","sha":"63c1f204608082f43802788a7e2fed751b3aa79f","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Unified
search","backport:prev-minor","v8.8.0","v8.9.0"],"number":156329,"url":"https://github.com/elastic/kibana/pull/156329","mergeCommit":{"message":"[Unified
search] Fixes the bar suggestions method selection (#156329)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155801\r\n\r\nFixes the bug
described
here\r\nhttps://github.com/elastic/kibana/issues/155801\r\n\r\nThe bug
was introduced
by\r\nhttps://github.com/elastic/kibana/pull/154522/files\r\n\r\nIf the
filtersForSuggestions prop is there, we want to default to\r\nterms_agg,
otherwise we want to keep it as undefined to use the
advanced\r\nsettings
method.","sha":"63c1f204608082f43802788a7e2fed751b3aa79f"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156329","number":156329,"mergeCommit":{"message":"[Unified
search] Fixes the bar suggestions method selection (#156329)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/155801\r\n\r\nFixes the bug
described
here\r\nhttps://github.com/elastic/kibana/issues/155801\r\n\r\nThe bug
was introduced
by\r\nhttps://github.com/elastic/kibana/pull/154522/files\r\n\r\nIf the
filtersForSuggestions prop is there, we want to default to\r\nterms_agg,
otherwise we want to keep it as undefined to use the
advanced\r\nsettings
method.","sha":"63c1f204608082f43802788a7e2fed751b3aa79f"}}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-03 05:31:09 -04:00 committed by GitHub
parent e86a6e1ff6
commit ef230e5854
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -88,7 +88,7 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends React.Com
signal: this.abortController.signal,
useTimeRange: timeRangeForSuggestionsOverride,
boolFilter: buildQueryFromFilters(filtersForSuggestions, undefined).filter,
method: filtersForSuggestions?.length ? 'terms_agg' : 'terms_enum',
method: filtersForSuggestions?.length ? 'terms_agg' : undefined,
});
this.setState({ suggestions, isLoading: false });

View file

@ -286,7 +286,7 @@ export default class QueryStringInputUI extends PureComponent<QueryStringInputPr
signal: this.abortController.signal,
useTimeRange: this.props.timeRangeForSuggestionsOverride,
boolFilter: buildQueryFromFilters(this.props.filtersForSuggestions, undefined).filter,
method: this.props.filtersForSuggestions?.length ? 'terms_agg' : 'terms_enum',
method: this.props.filtersForSuggestions?.length ? 'terms_agg' : undefined,
})) || [];
return [...suggestions, ...recentSearchSuggestions];
} catch (e) {