Skip to content

Commit c3d876e

Browse files
Merge branch 'master' into fix/dupe-data-streams
2 parents 36c152e + 391ab72 commit c3d876e

File tree

64 files changed

+2027
-305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2027
-305
lines changed

packages/kbn-es/src/cluster.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ exports.Cluster = class Cluster {
246246
this._log.info(chalk.bold('Starting'));
247247
this._log.indent(4);
248248

249-
const esArgs = ['indices.query.bool.max_nested_depth=100'].concat(options.esArgs || []);
249+
const esArgs = options.esArgs || [];
250250

251251
// Add to esArgs if ssl is enabled
252252
if (this._ssl) {

packages/kbn-es/src/integration_tests/cluster.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ describe('#start(installPath)', () => {
264264
expect(extractConfigFiles.mock.calls).toMatchInlineSnapshot(`
265265
Array [
266266
Array [
267-
Array [
268-
"indices.query.bool.max_nested_depth=100",
269-
],
267+
Array [],
270268
undefined,
271269
Object {
272270
"log": <ToolingLog>,
@@ -342,9 +340,7 @@ describe('#run()', () => {
342340
expect(extractConfigFiles.mock.calls).toMatchInlineSnapshot(`
343341
Array [
344342
Array [
345-
Array [
346-
"indices.query.bool.max_nested_depth=100",
347-
],
343+
Array [],
348344
undefined,
349345
Object {
350346
"log": <ToolingLog>,
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* and the Server Side Public License, v 1; you may not use this file except in
5+
* compliance with, at your election, the Elastic License or the Server Side
6+
* Public License, v 1.
7+
*/
8+
9+
import { nodeBuilder } from './node_builder';
10+
import { toElasticsearchQuery } from '../index';
11+
12+
describe('nodeBuilder', () => {
13+
describe('is method', () => {
14+
test('string value', () => {
15+
const nodes = nodeBuilder.is('foo', 'bar');
16+
const query = toElasticsearchQuery(nodes);
17+
expect(query).toMatchInlineSnapshot(`
18+
Object {
19+
"bool": Object {
20+
"minimum_should_match": 1,
21+
"should": Array [
22+
Object {
23+
"match": Object {
24+
"foo": "bar",
25+
},
26+
},
27+
],
28+
},
29+
}
30+
`);
31+
});
32+
33+
test('KueryNode value', () => {
34+
const literalValue = {
35+
type: 'literal' as 'literal',
36+
value: 'bar',
37+
};
38+
const nodes = nodeBuilder.is('foo', literalValue);
39+
const query = toElasticsearchQuery(nodes);
40+
expect(query).toMatchInlineSnapshot(`
41+
Object {
42+
"bool": Object {
43+
"minimum_should_match": 1,
44+
"should": Array [
45+
Object {
46+
"match": Object {
47+
"foo": "bar",
48+
},
49+
},
50+
],
51+
},
52+
}
53+
`);
54+
});
55+
});
56+
57+
describe('and method', () => {
58+
test('single clause', () => {
59+
const nodes = [nodeBuilder.is('foo', 'bar')];
60+
const query = toElasticsearchQuery(nodeBuilder.and(nodes));
61+
expect(query).toMatchInlineSnapshot(`
62+
Object {
63+
"bool": Object {
64+
"minimum_should_match": 1,
65+
"should": Array [
66+
Object {
67+
"match": Object {
68+
"foo": "bar",
69+
},
70+
},
71+
],
72+
},
73+
}
74+
`);
75+
});
76+
77+
test('two clauses', () => {
78+
const nodes = [nodeBuilder.is('foo1', 'bar1'), nodeBuilder.is('foo2', 'bar2')];
79+
const query = toElasticsearchQuery(nodeBuilder.and(nodes));
80+
expect(query).toMatchInlineSnapshot(`
81+
Object {
82+
"bool": Object {
83+
"filter": Array [
84+
Object {
85+
"bool": Object {
86+
"minimum_should_match": 1,
87+
"should": Array [
88+
Object {
89+
"match": Object {
90+
"foo1": "bar1",
91+
},
92+
},
93+
],
94+
},
95+
},
96+
Object {
97+
"bool": Object {
98+
"minimum_should_match": 1,
99+
"should": Array [
100+
Object {
101+
"match": Object {
102+
"foo2": "bar2",
103+
},
104+
},
105+
],
106+
},
107+
},
108+
],
109+
},
110+
}
111+
`);
112+
});
113+
114+
test('three clauses', () => {
115+
const nodes = [
116+
nodeBuilder.is('foo1', 'bar1'),
117+
nodeBuilder.is('foo2', 'bar2'),
118+
nodeBuilder.is('foo3', 'bar3'),
119+
];
120+
const query = toElasticsearchQuery(nodeBuilder.and(nodes));
121+
expect(query).toMatchInlineSnapshot(`
122+
Object {
123+
"bool": Object {
124+
"filter": Array [
125+
Object {
126+
"bool": Object {
127+
"minimum_should_match": 1,
128+
"should": Array [
129+
Object {
130+
"match": Object {
131+
"foo1": "bar1",
132+
},
133+
},
134+
],
135+
},
136+
},
137+
Object {
138+
"bool": Object {
139+
"minimum_should_match": 1,
140+
"should": Array [
141+
Object {
142+
"match": Object {
143+
"foo2": "bar2",
144+
},
145+
},
146+
],
147+
},
148+
},
149+
Object {
150+
"bool": Object {
151+
"minimum_should_match": 1,
152+
"should": Array [
153+
Object {
154+
"match": Object {
155+
"foo3": "bar3",
156+
},
157+
},
158+
],
159+
},
160+
},
161+
],
162+
},
163+
}
164+
`);
165+
});
166+
});
167+
168+
describe('or method', () => {
169+
test('single clause', () => {
170+
const nodes = [nodeBuilder.is('foo', 'bar')];
171+
const query = toElasticsearchQuery(nodeBuilder.or(nodes));
172+
expect(query).toMatchInlineSnapshot(`
173+
Object {
174+
"bool": Object {
175+
"minimum_should_match": 1,
176+
"should": Array [
177+
Object {
178+
"match": Object {
179+
"foo": "bar",
180+
},
181+
},
182+
],
183+
},
184+
}
185+
`);
186+
});
187+
188+
test('two clauses', () => {
189+
const nodes = [nodeBuilder.is('foo1', 'bar1'), nodeBuilder.is('foo2', 'bar2')];
190+
const query = toElasticsearchQuery(nodeBuilder.or(nodes));
191+
expect(query).toMatchInlineSnapshot(`
192+
Object {
193+
"bool": Object {
194+
"minimum_should_match": 1,
195+
"should": Array [
196+
Object {
197+
"bool": Object {
198+
"minimum_should_match": 1,
199+
"should": Array [
200+
Object {
201+
"match": Object {
202+
"foo1": "bar1",
203+
},
204+
},
205+
],
206+
},
207+
},
208+
Object {
209+
"bool": Object {
210+
"minimum_should_match": 1,
211+
"should": Array [
212+
Object {
213+
"match": Object {
214+
"foo2": "bar2",
215+
},
216+
},
217+
],
218+
},
219+
},
220+
],
221+
},
222+
}
223+
`);
224+
});
225+
226+
test('three clauses', () => {
227+
const nodes = [
228+
nodeBuilder.is('foo1', 'bar1'),
229+
nodeBuilder.is('foo2', 'bar2'),
230+
nodeBuilder.is('foo3', 'bar3'),
231+
];
232+
const query = toElasticsearchQuery(nodeBuilder.or(nodes));
233+
expect(query).toMatchInlineSnapshot(`
234+
Object {
235+
"bool": Object {
236+
"minimum_should_match": 1,
237+
"should": Array [
238+
Object {
239+
"bool": Object {
240+
"minimum_should_match": 1,
241+
"should": Array [
242+
Object {
243+
"match": Object {
244+
"foo1": "bar1",
245+
},
246+
},
247+
],
248+
},
249+
},
250+
Object {
251+
"bool": Object {
252+
"minimum_should_match": 1,
253+
"should": Array [
254+
Object {
255+
"match": Object {
256+
"foo2": "bar2",
257+
},
258+
},
259+
],
260+
},
261+
},
262+
Object {
263+
"bool": Object {
264+
"minimum_should_match": 1,
265+
"should": Array [
266+
Object {
267+
"match": Object {
268+
"foo3": "bar3",
269+
},
270+
},
271+
],
272+
},
273+
},
274+
],
275+
},
276+
}
277+
`);
278+
});
279+
});
280+
});

src/plugins/data/common/es_query/kuery/node_types/node_builder.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ export const nodeBuilder = {
1616
nodeTypes.literal.buildNode(false),
1717
]);
1818
},
19-
or: ([first, ...args]: KueryNode[]): KueryNode => {
20-
return args.length ? nodeTypes.function.buildNode('or', [first, nodeBuilder.or(args)]) : first;
19+
or: (nodes: KueryNode[]): KueryNode => {
20+
return nodes.length > 1 ? nodeTypes.function.buildNode('or', nodes) : nodes[0];
2121
},
22-
and: ([first, ...args]: KueryNode[]): KueryNode => {
23-
return args.length
24-
? nodeTypes.function.buildNode('and', [first, nodeBuilder.and(args)])
25-
: first;
22+
and: (nodes: KueryNode[]): KueryNode => {
23+
return nodes.length > 1 ? nodeTypes.function.buildNode('and', nodes) : nodes[0];
2624
},
2725
};

0 commit comments

Comments
 (0)