Skip to content

[SearchBar] Use bool query instead of match bool logic - #6220

Merged
PhaedrusTheGreek merged 3 commits into
elastic:mainfrom
PhaedrusTheGreek:use-bool-for-field-value-dsl
Sep 8, 2022
Merged

PhaedrusTheGreek merged 3 commits into
elastic:mainfrom
PhaedrusTheGreek:use-bool-for-field-value-dsl

Conversation

@PhaedrusTheGreek

Copy link
Copy Markdown
Contributor

Summary

This replaces a single match query with bool should or must logic in Query.toESQuery(). As a match query, fields with non-text mappings were failing search due to reliance on a text analyzer which doesn't exist in that case.

closes #6217

Checklist

@kibanamachine

Copy link
Copy Markdown
Contributor

@thompsongl

Copy link
Copy Markdown
Contributor

Makes sense to me. I'd like to have @chandlerprall look also as he's much more familiar with this code.

@chandlerprall chandlerprall left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change LGTM, most of the snapshot changes LGTM (I've never been good at ES queries), @PhaedrusTheGreek would you mind verifying this snapshot DSL performs its intent?

exports[`astToEsQueryDsl ast - 'john group:(eng or "marketing org") -group:"kibana team" 1`] = `
Object {
"bool": Object {
"must": Array [
Object {
"simple_query_string": Object {
"query": "john",
},
},
Object {
"bool": Object {
"should": Array [
Object {
"bool": Object {
"should": Array [
Object {
"match": Object {
"group": "eng",
},
},
],
},
},
Object {
"match_phrase": Object {
"group": "marketing org",
},
},
],
},
},
],
"must_not": Array [
Object {
"match_phrase": Object {
"group": "kibana team",
},
},
],
},
}
`;

@PhaedrusTheGreek

Copy link
Copy Markdown
Contributor Author

@chandlerprall @thompsongl , the snapshot DSL does look correct, aside from the unnecessary bool on a single clause, fix for which I just pushed.

@chandlerprall chandlerprall left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional changes LGTM (nice differentiating on term count!); Needs a changelog entry, the process for creating one is at https://github.com/elastic/eui/blob/main/wiki/documentation-guidelines.md#changelog - shout if something in that doc doesn't work as expected

@kibanamachine

Copy link
Copy Markdown
Contributor

@kibanamachine

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SearchBar] Field value selection doesn't work on keyword fields by default

4 participants