Skip to content

Commit 138fb6f

Browse files
committed
Added extra tests with background filters
1 parent 2f723f3 commit 138fb6f

File tree

1 file changed

+186
-0
lines changed

1 file changed

+186
-0
lines changed

modules/aggregations/src/yamlRestTest/resources/rest-api-spec/test/aggregations/sig_terms_nested.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,92 @@ setup:
215215
- match: {aggregations.significant_terms_keyword.buckets.0.bg_count: 5}
216216
- close_to: { aggregations.significant_terms_keyword.buckets.0.score: {value: 0.3, error: 0.000001 }}
217217

218+
---
219+
"Normal fields with neutral background filter":
220+
- do:
221+
search:
222+
size: 0
223+
rest_total_hits_as_int: true
224+
index: test
225+
body: {
226+
"query": {
227+
"terms": { "type": [ "outlier" ] }
228+
},
229+
"aggs": {
230+
"significant_terms": {
231+
"significant_terms": {
232+
"field": "value",
233+
"background_filter": {
234+
"terms": { "type": ["normal", "outlier"] }
235+
}
236+
}
237+
},
238+
"significant_terms_keyword": {
239+
"significant_terms": {
240+
"field": "value_keyword",
241+
"background_filter": {
242+
"terms": { "type": ["normal", "outlier"] }
243+
}
244+
}
245+
}
246+
}
247+
}
248+
249+
- match: {aggregations.significant_terms.doc_count: 8}
250+
- match: {aggregations.significant_terms.bg_count: 16}
251+
- length: {aggregations.significant_terms.buckets: 1}
252+
- match: {aggregations.significant_terms.buckets.0.key: 2}
253+
- match: {aggregations.significant_terms.buckets.0.doc_count: 4}
254+
- match: {aggregations.significant_terms.buckets.0.bg_count: 5}
255+
- close_to: { aggregations.significant_terms.buckets.0.score: {value: 0.3, error: 0.000001 }}
256+
257+
- match: {aggregations.significant_terms_keyword.doc_count: 8}
258+
- match: {aggregations.significant_terms_keyword.bg_count: 16}
259+
- length: {aggregations.significant_terms_keyword.buckets: 1}
260+
- match: {aggregations.significant_terms_keyword.buckets.0.key: "2"}
261+
- match: {aggregations.significant_terms_keyword.buckets.0.doc_count: 4}
262+
- match: {aggregations.significant_terms_keyword.buckets.0.bg_count: 5}
263+
- close_to: { aggregations.significant_terms_keyword.buckets.0.score: {value: 0.3, error: 0.000001 }}
264+
265+
---
266+
"Normal fields with background filter":
267+
- do:
268+
search:
269+
size: 0
270+
rest_total_hits_as_int: true
271+
index: test
272+
body: {
273+
"query": {
274+
"terms": { "type": [ "outlier" ] }
275+
},
276+
"aggs": {
277+
"significant_terms": {
278+
"significant_terms": {
279+
"field": "value",
280+
"background_filter": {
281+
"terms": { "type": ["outlier"] }
282+
}
283+
}
284+
},
285+
"significant_terms_keyword": {
286+
"significant_terms": {
287+
"field": "value_keyword",
288+
"background_filter": {
289+
"terms": { "type": ["outlier"] }
290+
}
291+
}
292+
}
293+
}
294+
}
295+
296+
- match: {aggregations.significant_terms.doc_count: 8}
297+
- match: {aggregations.significant_terms.bg_count: 8}
298+
- length: {aggregations.significant_terms.buckets: 0}
299+
300+
- match: {aggregations.significant_terms_keyword.doc_count: 8}
301+
- match: {aggregations.significant_terms_keyword.bg_count: 8}
302+
- length: {aggregations.significant_terms_keyword.buckets: 0}
303+
218304
---
219305
"Nested fields":
220306
- do:
@@ -263,6 +349,106 @@ setup:
263349
- match: {aggregations.nested.significant_terms_keyword.buckets.0.bg_count: 5}
264350
- close_to: { aggregations.nested.significant_terms_keyword.buckets.0.score: {value: 0.3, error: 0.000001 }}
265351

352+
---
353+
"Nested fields with neutral background filter":
354+
- do:
355+
search:
356+
size: 0
357+
rest_total_hits_as_int: true
358+
index: test
359+
body: {
360+
"query": {
361+
"terms": { "type": [ "outlier" ] }
362+
},
363+
"aggs": {
364+
"nested": {
365+
"nested": {
366+
"path": "nested"
367+
},
368+
"aggs": {
369+
"significant_terms": {
370+
"significant_terms": {
371+
"field": "nested.value",
372+
"background_filter": {
373+
"terms": { "type": ["normal", "outlier"] }
374+
}
375+
}
376+
},
377+
"significant_terms_keyword": {
378+
"significant_terms": {
379+
"field": "nested.value_keyword",
380+
"background_filter": {
381+
"terms": { "type": ["normal", "outlier"] }
382+
}
383+
}
384+
}
385+
}
386+
}
387+
}
388+
}
389+
390+
- match: {aggregations.nested.significant_terms.doc_count: 8}
391+
- match: {aggregations.nested.significant_terms.bg_count: 16}
392+
- length: {aggregations.nested.significant_terms.buckets: 1}
393+
- match: {aggregations.nested.significant_terms.buckets.0.key: 2}
394+
- match: {aggregations.nested.significant_terms.buckets.0.doc_count: 4}
395+
- match: {aggregations.nested.significant_terms.buckets.0.bg_count: 5}
396+
- close_to: { aggregations.nested.significant_terms.buckets.0.score: {value: 0.3, error: 0.000001 }}
397+
398+
- match: {aggregations.nested.significant_terms_keyword.doc_count: 8}
399+
- match: {aggregations.nested.significant_terms_keyword.bg_count: 16}
400+
- length: {aggregations.nested.significant_terms_keyword.buckets: 1}
401+
- match: {aggregations.nested.significant_terms_keyword.buckets.0.key: "2"}
402+
- match: {aggregations.nested.significant_terms_keyword.buckets.0.doc_count: 4}
403+
- match: {aggregations.nested.significant_terms_keyword.buckets.0.bg_count: 5}
404+
- close_to: { aggregations.nested.significant_terms_keyword.buckets.0.score: {value: 0.3, error: 0.000001 }}
405+
406+
---
407+
"Nested fields with background filter":
408+
- do:
409+
search:
410+
size: 0
411+
rest_total_hits_as_int: true
412+
index: test
413+
body: {
414+
"query": {
415+
"terms": { "type": [ "outlier" ] }
416+
},
417+
"aggs": {
418+
"nested": {
419+
"nested": {
420+
"path": "nested"
421+
},
422+
"aggs": {
423+
"significant_terms": {
424+
"significant_terms": {
425+
"field": "nested.value",
426+
"background_filter": {
427+
"terms": { "type": ["outlier"] }
428+
}
429+
}
430+
},
431+
"significant_terms_keyword": {
432+
"significant_terms": {
433+
"field": "nested.value_keyword",
434+
"background_filter": {
435+
"terms": { "type": ["outlier"] }
436+
}
437+
}
438+
}
439+
}
440+
}
441+
}
442+
}
443+
444+
- match: {aggregations.nested.significant_terms.doc_count: 8}
445+
- match: {aggregations.nested.significant_terms.bg_count: 8}
446+
- length: {aggregations.nested.significant_terms.buckets: 0}
447+
448+
- match: {aggregations.nested.significant_terms_keyword.doc_count: 8}
449+
- match: {aggregations.nested.significant_terms_keyword.bg_count: 8}
450+
- length: {aggregations.nested.significant_terms_keyword.buckets: 0}
451+
266452
---
267453
"Doubly nested fields":
268454
- do:

0 commit comments

Comments
 (0)