-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added aggregation tests for avg, max, min, range, terms, sum, nested …
…and histogram. (#576) * Add aggregation tests for nested Signed-off-by: kkewwei <[email protected]> Signed-off-by: kewei.11 <[email protected]> * Added aggregation tests for avg, max, min, range, terms, sum and histogram. Signed-off-by: dblock <[email protected]> Signed-off-by: kkewwei <[email protected]> --------- Signed-off-by: kkewwei <[email protected]> Signed-off-by: kewei.11 <[email protected]> Signed-off-by: dblock <[email protected]> Co-authored-by: dblock <[email protected]>
- Loading branch information
Showing
10 changed files
with
364 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test avg aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, duration: 126} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, duration: 100} | ||
chapters: | ||
- synopsis: Aggregate with avg. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
duration_avg: | ||
avg: | ||
field: duration | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
duration_avg: | ||
value: 113 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test histogram aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, year: 2011} | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: The Cruise, year: 1998} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, year: 1960} | ||
chapters: | ||
- synopsis: Aggregate with histogram. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
movies: | ||
histogram: | ||
field: year | ||
interval: 100 | ||
format: '##0.0' | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
movies: | ||
buckets: | ||
- key_as_string: '1900.0' | ||
key: 1900 | ||
doc_count: 2 | ||
- key_as_string: '2000.0' | ||
key: 2000 | ||
doc_count: 1 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test max aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, duration: 126} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, duration: 100} | ||
chapters: | ||
- synopsis: Aggregate with max. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
duration_max: | ||
max: | ||
field: duration | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
duration_max: | ||
value: 126 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test min aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, duration: 126} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, duration: 100} | ||
chapters: | ||
- synopsis: Aggregate with min. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
duration_min: | ||
min: | ||
field: duration | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
duration_min: | ||
value: 100 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test aggregation. | ||
prologues: | ||
- path: books | ||
method: PUT | ||
request: | ||
payload: | ||
mappings: | ||
properties: | ||
details: | ||
type: nested | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {index: {_index: books, _id: '0'}} | ||
- {details: {title: title1}} | ||
- {index: {_index: books, _id: '1'}} | ||
- {details: {title: title2}} | ||
chapters: | ||
- synopsis: Aggregation with nested. | ||
path: /{index}/_search | ||
parameters: | ||
index: books | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
details_agg: | ||
nested: | ||
path: details | ||
response: | ||
status: 200 | ||
payload: | ||
timed_out: false | ||
_shards: | ||
total: 1 | ||
successful: 1 | ||
skipped: 0 | ||
failed: 0 | ||
hits: | ||
total: | ||
value: 2 | ||
relation: eq | ||
max_score: null | ||
hits: [] | ||
aggregations: | ||
details_agg: | ||
doc_count: 2 | ||
|
||
epilogues: | ||
- path: /books | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test range aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, year: 2011} | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: The Cruise, year: 1998} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, year: 1960} | ||
chapters: | ||
- synopsis: Aggregate with range. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
20th_century: | ||
range: | ||
field: year | ||
ranges: | ||
- from: 1900 | ||
to: 2000 | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
20th_century: | ||
buckets: | ||
- from: 1900 | ||
to: 2000 | ||
doc_count: 2 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test sum aggregation. | ||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball, duration: 126} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive, duration: 100} | ||
chapters: | ||
- synopsis: Aggregate with sum. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
duration_sum: | ||
sum: | ||
field: duration | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
duration_sum: | ||
value: 226 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test terms aggregation. | ||
prologues: | ||
- path: /movies | ||
method: PUT | ||
request: | ||
payload: | ||
mappings: | ||
properties: | ||
director: | ||
type: text | ||
fielddata: true | ||
fields: | ||
raw: | ||
type: keyword | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: Moneyball} | ||
- {create: {_index: movies}} | ||
- {director: Bennett Miller, title: The Cruise} | ||
- {create: {_index: movies}} | ||
- {director: Nicolas Winding Refn, title: Drive} | ||
chapters: | ||
- synopsis: Aggregate with terms. | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
method: POST | ||
request: | ||
payload: | ||
size: 0 | ||
aggregations: | ||
directors: | ||
terms: | ||
field: director.raw | ||
response: | ||
status: 200 | ||
payload: | ||
aggregations: | ||
directors: | ||
buckets: | ||
- key: Bennett Miller | ||
doc_count: 2 | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] |