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 d9fe829
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.
version: '>= 2.17'
prologues:
- path: books
method: PUT
request_body:
payload:
mappings:
properties:
details:
type: nested
properties:
title:
type: keyword
doc:
type: nested
properties:
chapters:
type: nested
properties:
pages:
type: keyword
- path: /_bulk
method: POST
request_body:
content_type: application/x-ndjson
payload:
- {index: {_index: books, _id: '0'}}
- {details: {title: title1, doc: {chapters: {pages: 10, chapter_title: chapter_title1}}}}
- {index: {_index: books, _id: '1'}}
- {details: {title: title2, doc: {chapters: {pages: 15, chapter_title: chapter_title2}}}}
chapters:
- synopsis: aggregation with nested.
path: /books/_search
method: POST
request_body:
payload:
size: 0
aggregation:
nested_agg:
nested:
path: details
aggregation:
a_b1:
terms:
field: details.title
aggregation:
chapters:
nested:
path: details.doc.chapters
aggregation:
pages:
terms:
field: details.doc.chapters.pages
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: title1
doc_count: 1
chapters:
doc_count: 1
pages:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: 10
doc_count: 1
- key: title2
doc_count: 1
chapters:
doc_count: 1
pages:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: 15
doc_count: 1
epilogues:
- path: /books
method: DELETE
status: [200, 404]

0 comments on commit d9fe829

Please sign in to comment.