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]>
  • Loading branch information
kkewwei committed Sep 14, 2024
1 parent c2c666f commit 680bad4
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Rename `Bytes` component to `StorageType` ([#552](https://github.com/opensearch-project/opensearch-api-specification/pull/552))
- Rename `ByteSize` to `StorageSize` ([#552](https://github.com/opensearch-project/opensearch-api-specification/pull/552))
- Split `Percentage` into `PercentageNumber`, `PercentageString` ([#573](https://github.com/opensearch-project/opensearch-api-specification/pull/573))
- Add test about nested aggregation ([#576](https://github.com/opensearch-project/opensearch-api-specification/issues/576))

### Deprecated

Expand Down
100 changes: 100 additions & 0 deletions tests/default/_core/aggregation/nested.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test aggregation endpoints with nested.
prologues:
- path: movies
method: PUT
request_body:
payload:
mappings:
properties:
a:
type: nested
properties:
b1:
type: keyword
b2:
type: nested
properties:
c:
type: nested
properties:
d:
type: keyword

chapters:
- synopsis: Bulk document.
path: /_bulk
method: POST
request_body:
content_type: application/x-ndjson
payload:
- {index: {"_index": "movies", "_id": "0"}}
- {"a": { "b1": "b11", "b2": { "c": { "d": "d1" } }}}
- {"index": {"_index": "movies", "_id": "1"}}
- {"a": { "b1": "b12", "b2": { "c": { "d": "d2" } }}}

- synopsis: aggregation with nested.
path: /movies/_search
method: POST
request_body:
payload:
size: 0
aggs:
nested_agg:
nested:
path: a
aggs:
a_b1:
terms:
field: a.b1
aggs:
c:
nested:
path: a.b2.c
aggs:
d:
terms:
field: a.b2.c.d

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: b11
doc_count: 1
c:
doc_count: 1
d:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: d1
doc_count: 1
- key: b12
doc_count: 1
c:
doc_count: 1
d:
doc_count_error_upper_bound: 0
sum_other_doc_count: 0
buckets:
- key: d1
doc_count: 1

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

0 comments on commit 680bad4

Please sign in to comment.