Skip to content

Commit 24aed30

Browse files
authored
A few more tests for parent and child aggs (#78264) (#78640)
In our effort to get comprehensive rest tests for aggs (#26220) I've added a few more tests for the `parent` and `child` aggs. The aggs themselves don't have a ton of configuration, but I added a few examples of running them inside of other aggs.
1 parent ecf46e0 commit 24aed30

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/40_aggregations.yml

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ setup:
77
number_of_shards: 2 #Two shards proves that we route properly
88
mappings:
99
properties:
10-
join_field: { "type": "join", "relations": { "parent": "child", "child": "grand_child" } }
11-
id: { "type": "keyword" }
10+
join_field:
11+
type: join
12+
relations:
13+
parent: child
14+
child: grand_child
15+
id:
16+
type: keyword
1217

1318
- do:
1419
bulk:
@@ -29,7 +34,7 @@ setup:
2934
- '{ "join_field": { "name": "grand_child", "parent": "5" } }'
3035

3136
---
32-
unconfigured:
37+
unconfigured children:
3338
- do:
3439
index:
3540
index: test_unconfigured
@@ -53,6 +58,31 @@ unconfigured:
5358
- match: { hits.total.value: 1 }
5459
- match: { aggregations.to-answers.doc_count: 0 }
5560

61+
---
62+
unconfigured parent:
63+
- do:
64+
index:
65+
index: test_unconfigured
66+
refresh: true
67+
body:
68+
join:
69+
name: question
70+
body: <p>I have Windows 2003 server and i bought a new Windows 2008 server...,
71+
title: Whats the best way to file transfer my site from server to a newer one?,
72+
tags: [windows-server-2003, windows-server-2008, file-transfer]
73+
74+
- do:
75+
search:
76+
index: test_unconfigured
77+
body:
78+
size: 0
79+
aggs:
80+
to-answers:
81+
parent:
82+
type: answer
83+
- match: { hits.total.value: 1 }
84+
- match: { aggregations.to-answers.doc_count: 0 }
85+
5686
---
5787
children:
5888
- do:
@@ -173,3 +203,50 @@ parent terms terms:
173203
- match: { aggregations.parent.tag.buckets.0.subject.buckets.0.key: surprises }
174204
- match: { aggregations.parent.tag.buckets.1.key: jumble }
175205
- match: { aggregations.parent.tag.buckets.1.subject.buckets.0.key: critters }
206+
207+
---
208+
term children:
209+
- do:
210+
search:
211+
index: test
212+
body:
213+
size: 0
214+
aggs:
215+
subject:
216+
terms:
217+
field: subject.keyword
218+
aggs:
219+
children:
220+
children:
221+
type: child
222+
- match: { hits.total.value: 6 }
223+
- match: { aggregations.subject.buckets.0.key: critters }
224+
- match: { aggregations.subject.buckets.0.doc_count: 1 }
225+
- match: { aggregations.subject.buckets.0.children.doc_count: 1 }
226+
- match: { aggregations.subject.buckets.1.key: surprises }
227+
- match: { aggregations.subject.buckets.1.doc_count: 1 }
228+
- match: { aggregations.subject.buckets.1.children.doc_count: 2 }
229+
230+
---
231+
term parent:
232+
- do:
233+
search:
234+
index: test
235+
body:
236+
size: 0
237+
aggs:
238+
animal:
239+
terms:
240+
field: animal.keyword
241+
aggs:
242+
parent:
243+
parent:
244+
type: child
245+
- match: { hits.total.value: 6 }
246+
- match: { aggregations.animal.buckets.0.key: dog }
247+
- match: { aggregations.animal.buckets.0.doc_count: 2 }
248+
- match: { aggregations.animal.buckets.0.parent.doc_count: 2 }
249+
- match: { aggregations.animal.buckets.1.key: cat }
250+
- match: { aggregations.animal.buckets.1.doc_count: 1 }
251+
- match: { aggregations.animal.buckets.1.parent.doc_count: 1 }
252+

0 commit comments

Comments
 (0)