forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test for sample aggragator (elastic#77807)
Adds and integration test for the sample aggregator. It's a fairly simple aggregator - you can only chose how many documents it samples.
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
...api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/400_sampler.yml
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,79 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
mappings: | ||
properties: | ||
tags: | ||
type: text | ||
number: | ||
type: integer | ||
|
||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{"index": {}}' | ||
- '{"tags": "kibana", "number": 1}' | ||
- '{"index": {}}' | ||
- '{"tags": "kibana", "number": 2}' | ||
- '{"index": {}}' | ||
- '{"tags": "kibana", "number": 3}' | ||
- '{"index": {}}' | ||
- '{"tags": "javascript", "number": 4}' | ||
|
||
--- | ||
small shard_size: | ||
- do: | ||
search: | ||
body: | ||
query: | ||
query_string: | ||
query: 'tags:kibana OR tags:javascript' | ||
aggs: | ||
sample: | ||
sampler: | ||
shard_size: 1 | ||
aggs: | ||
min_number: | ||
min: | ||
field: number | ||
max_number: | ||
max: | ||
field: number | ||
|
||
|
||
- match: { hits.total.value: 4 } | ||
- match: { aggregations.sample.doc_count: 1 } | ||
# The document with 4 has the highest score so we pick that one. | ||
- match: { aggregations.sample.min_number.value: 4.0 } | ||
- match: { aggregations.sample.max_number.value: 4.0 } | ||
|
||
--- | ||
default shard size: | ||
- do: | ||
search: | ||
body: | ||
query: | ||
query_string: | ||
query: 'tags:kibana OR tags:javascript' | ||
aggs: | ||
sample: | ||
sampler: {} | ||
aggs: | ||
min_number: | ||
min: | ||
field: number | ||
max_number: | ||
max: | ||
field: number | ||
|
||
- match: { hits.total.value: 4 } | ||
# The default shard size is much larger than the four test documents we are working with | ||
- match: { aggregations.sample.doc_count: 4 } | ||
- match: { aggregations.sample.min_number.value: 1.0 } | ||
- match: { aggregations.sample.max_number.value: 4.0 } |