mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Fix autocomplete value suggestions to exclude tiers (#176355)
## Summary Resolves https://github.com/elastic/kibana/issues/165264. When querying ES for value suggestions (KQL & filter editor), this PR updates the behavior to filter *out* (instead of filter *for*) tiers. This ensures that for those indices without a tier preference set, the values will still show up. The tiers are controlled by a config setting, `data.autocomplete.valueSuggestions.tiers`. This may have already been set, so we preserve the existing settings when querying. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### Release notes Autocomplete value suggestions for KQL and filters will now return suggestions even when the corresponding index has no tier preference set. --------- Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
This commit is contained in:
parent
5244569476
commit
534c337831
2 changed files with 37 additions and 41 deletions
|
@ -57,17 +57,15 @@ describe('_terms_enum suggestions', () => {
|
|||
"field": "field_name",
|
||||
"index_filter": Object {
|
||||
"bool": Object {
|
||||
"must": Array [
|
||||
Object {
|
||||
"terms": Object {
|
||||
"_tier": Array [
|
||||
"data_hot",
|
||||
"data_warm",
|
||||
"data_content",
|
||||
],
|
||||
},
|
||||
"must": Array [],
|
||||
"must_not": Object {
|
||||
"terms": Object {
|
||||
"_tier": Array [
|
||||
"data_cold",
|
||||
"data_frozen",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"string": "query",
|
||||
|
@ -97,17 +95,15 @@ describe('_terms_enum suggestions', () => {
|
|||
"field": "fieldName",
|
||||
"index_filter": Object {
|
||||
"bool": Object {
|
||||
"must": Array [
|
||||
Object {
|
||||
"terms": Object {
|
||||
"_tier": Array [
|
||||
"data_hot",
|
||||
"data_warm",
|
||||
"data_content",
|
||||
],
|
||||
},
|
||||
"must": Array [],
|
||||
"must_not": Object {
|
||||
"terms": Object {
|
||||
"_tier": Array [
|
||||
"data_cold",
|
||||
"data_frozen",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"string": "query",
|
||||
|
|
|
@ -23,36 +23,36 @@ export async function termsEnumSuggestions(
|
|||
field?: FieldSpec,
|
||||
abortSignal?: AbortSignal
|
||||
) {
|
||||
// See https://github.com/elastic/kibana/issues/165264
|
||||
const { tiers } = config.autocomplete.valueSuggestions;
|
||||
const excludedTiers = [
|
||||
'data_content',
|
||||
'data_hot',
|
||||
'data_warm',
|
||||
'data_cold',
|
||||
'data_frozen',
|
||||
].filter((tier) => !tiers.includes(tier));
|
||||
|
||||
if (!field?.name && !field?.type) {
|
||||
const indexPattern = await findIndexPatternById(savedObjectsClient, index);
|
||||
field = indexPattern && getFieldByName(fieldName, indexPattern);
|
||||
}
|
||||
|
||||
const result = await esClient.termsEnum(
|
||||
{
|
||||
index,
|
||||
body: {
|
||||
field: field?.name ?? fieldName,
|
||||
string: query,
|
||||
index_filter: {
|
||||
bool: {
|
||||
must: [
|
||||
...(filters ?? []),
|
||||
{
|
||||
terms: {
|
||||
_tier: tiers,
|
||||
},
|
||||
},
|
||||
],
|
||||
const body = {
|
||||
field: field?.name ?? fieldName,
|
||||
string: query,
|
||||
index_filter: {
|
||||
bool: {
|
||||
must: filters ?? [],
|
||||
must_not: {
|
||||
terms: {
|
||||
_tier: excludedTiers,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
signal: abortSignal,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return result.terms;
|
||||
const { terms } = await esClient.termsEnum({ index, body }, { signal: abortSignal });
|
||||
return terms;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue