Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,37 @@ Object {
"bool": Object {
"must": Array [
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "kibana logstash",
},
"bool": Object {
"must": Array [
Object {
"match": Object {
"group": "kibana",
},
},
Object {
"match": Object {
"group": "logstash",
},
},
],
},
},
],
"must_not": Array [
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "es beats",
},
"bool": Object {
"must": Array [
Object {
"match": Object {
"group": "es",
},
},
Object {
"match": Object {
"group": "beats",
},
},
],
},
},
],
Expand All @@ -44,10 +60,7 @@ Object {
},
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "kibana",
},
"group": "kibana",
},
},
Object {
Expand All @@ -70,11 +83,19 @@ Object {
},
},
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "eng es",
},
"bool": Object {
"must": Array [
Object {
"match": Object {
"group": "eng",
},
},
Object {
"match": Object {
"group": "es",
},
},
],
},
},
Object {
Expand All @@ -96,10 +117,7 @@ Object {
},
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "kibana",
},
"group": "kibana",
},
},
],
Expand Down Expand Up @@ -142,10 +160,7 @@ Object {
"should": Array [
Object {
"match": Object {
"group": Object {
"operator": "or",
"query": "eng",
},
"group": "eng",
},
},
Object {
Expand Down Expand Up @@ -178,21 +193,26 @@ Object {
},
},
Object {
"match": Object {
"group": Object {
"operator": "or",
"query": "eng es",
},
"bool": Object {
"should": Array [
Object {
"match": Object {
"group": "eng",
},
},
Object {
"match": Object {
"group": "es",
},
},
],
},
},
],
"must_not": Array [
Object {
"match": Object {
"group": Object {
"operator": "and",
"query": "kibana",
},
"group": "kibana",
},
},
],
Expand All @@ -212,10 +232,7 @@ Object {
"must": Array [
Object {
"match": Object {
"name": Object {
"operator": "and",
"query": "john",
},
"name": "john",
},
},
],
Expand All @@ -226,10 +243,7 @@ Object {
"must": Array [
Object {
"match": Object {
"name": Object {
"operator": "and",
"query": "fred",
},
"name": "fred",
},
},
],
Expand All @@ -255,10 +269,7 @@ Object {
"must": Array [
Object {
"match": Object {
"name": Object {
"operator": "and",
"query": "john",
},
"name": "john",
},
},
],
Expand Down Expand Up @@ -414,10 +425,7 @@ Object {
"must": Array [
Object {
"match": Object {
"name": Object {
"operator": "and",
"query": "john",
},
"name": "john",
},
},
],
Expand Down
23 changes: 12 additions & 11 deletions src/components/search_bar/query/ast_to_es_query_dsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
* Side Public License, v 1.
*/

import { printIso8601 } from './date_format';
import { isDateValue, dateValue, DateValue } from './date_value';
import { isArray, isDateLike, isString } from '../../../services/predicate';
import { keysOf } from '../../common';
import {
_AST,
AST,
FieldClause,
IsClause,
OperatorType,
TermClause,
Value,
_AST,
} from './ast';
import { isArray, isDateLike, isString } from '../../../services/predicate';
import { keysOf } from '../../common';
import { printIso8601 } from './date_format';
import { dateValue, DateValue, isDateValue } from './date_value';

export interface QueryContainer {
bool?: BoolQuery;
Expand Down Expand Up @@ -140,15 +140,16 @@ export const _fieldValuesToQuery = (
}
});

if (terms.length > 0) {
if (terms.length > 1) {
queries.push({
match: {
[field]: {
query: terms.join(' '),
operator: andOr,
},
bool: {
[andOr === 'and' ? 'must' : 'should']: [
...terms.map((value) => ({ match: { [field]: value } })),
],
},
});
} else if (terms.length === 1) {
queries.push({ match: { [field]: terms[0] } });
}

if (phrases.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/6220.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `Query.toESQuery()` to generate bool queries instead of relying on match query logic, to work with non-text fields