Skip to content

Commit

Permalink
Add test about nested aggregation
Browse files Browse the repository at this point in the history
Signed-off-by: kkewwei <[email protected]>
Signed-off-by: kewei.11 <[email protected]>
  • Loading branch information
kkewwei committed Sep 16, 2024
1 parent c2c666f commit 4068e1c
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/default/_core/search/aggs/nested_agg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test aggregation.
prologues:
- path: user_infos
method: PUT
request_body:
payload:
mappings:
properties:
user:
type: nested
properties:
name:
type: keyword
address:
type: nested
properties:
city:
type: nested
properties:
country:
type: keyword
- path: /_bulk
method: POST
request_body:
content_type: application/x-ndjson
payload:
- {index: {_index: user_infos, _id: '0'}}
- {user: {name: user1, address: {city: {country: country1}}}}
- {index: {_index: user_infos, _id: '1'}}
- {user: {name: user2, address: {city: {country: country2}}}}
chapters:
- synopsis: aggregation with nested.
path: /user_infos/_search
method: POST
request_body:
payload:
size: 0
aggregation:
nested_agg:
nested:
path: user
aggregation:
a_b1:
terms:
field: user.name
aggregation:
city:
nested:
path: user.address.city
aggregation:
country:
terms:
field: user.address.city.country
response:
status: 200
payload:
timed_out: false
hits:
total:
value: 2
relation: eq
hits: []
aggregations:
nested_agg:
doc_count: 2
a_b1:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: user1
doc_count: 1
city:
doc_count: 1
country:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: country1
doc_count: 1
- key: user2
doc_count: 1
city:
doc_count: 1
country:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: country2
doc_count: 1

epilogues:
- path: /user_infos
method: DELETE
status: [200, 404]

0 comments on commit 4068e1c

Please sign in to comment.