mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fix value suggestions API when the field and/or docs are not present (#17507)
This commit is contained in:
parent
9cf6e369c9
commit
82f915b885
1 changed files with 3 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
import { get, map } from 'lodash';
|
||||
import handleESError from '../../../lib/handle_es_error';
|
||||
|
||||
export function registerValueSuggestions(server) {
|
||||
|
@ -11,7 +12,8 @@ export function registerValueSuggestions(server) {
|
|||
const body = getBody({ field, query });
|
||||
try {
|
||||
const response = await callWithRequest(req, 'search', { index, body });
|
||||
const suggestions = response.aggregations.suggestions.buckets.map(bucket => bucket.key);
|
||||
const buckets = get(response, 'aggregations.suggestions.buckets') || [];
|
||||
const suggestions = map(buckets, 'key');
|
||||
reply(suggestions);
|
||||
} catch (error) {
|
||||
reply(handleESError(error));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue