forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add YAML REST tests for filters bucket agg
Related to elastic#26220
- Loading branch information
1 parent
f37eb1b
commit 59d0842
Showing
1 changed file
with
259 additions
and
0 deletions.
There are no files selected for viewing
259 changes: 259 additions & 0 deletions
259
...-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/220_filters_bucket.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,259 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test_1 | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
doc: | ||
properties: | ||
int_field: | ||
type : integer | ||
double_field: | ||
type : double | ||
string_field: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 1 | ||
- int_field: 1 | ||
double_field: 1.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 2 | ||
- int_field: 51 | ||
double_field: 51.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 3 | ||
- int_field: 101 | ||
double_field: 101.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 4 | ||
- int_field: 151 | ||
double_field: 151.0 | ||
string_field: foo | ||
|
||
--- | ||
"Basic test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: int_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.first_filter.the_avg.value: 101.0 } | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.the_avg.value: 151.0 } | ||
|
||
--- | ||
"Anonymous filters test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
- match: | ||
int_field: 101 | ||
- match: | ||
int_field: 151 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.0.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.1.doc_count: 1 } | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
- match: | ||
int_field: 101 | ||
- match: | ||
int_field: 151 | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: int_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.0.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.0.the_avg.value: 101.0 } | ||
- match: { aggregations.the_filter.buckets.1.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.1.the_avg.value: 151.0 } | ||
|
||
--- | ||
"Only aggs test": | ||
|
||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 0 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: int_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.first_filter.the_avg.value: 101.0 } | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.the_avg.value: 151.0 } | ||
|
||
--- | ||
"Filtered test": | ||
|
||
- do: | ||
search: | ||
body: | ||
query: | ||
constant_score: | ||
filter: | ||
range: | ||
int_field: | ||
gte: 110 | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: int_field | ||
|
||
- match: { hits.total: 1 } | ||
- length: { hits.hits: 1 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 0 } | ||
- is_false: aggregations.the_filter.buckets.first_filter.the_avg.value | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.the_avg.value: 151.0 } | ||
|
||
|
||
--- | ||
"Metadata test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
meta: | ||
foo: bar | ||
filters: | ||
filters: | ||
first_filter: | ||
match: | ||
int_field: 101 | ||
second_filter: | ||
match: | ||
int_field: 151 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_filter.buckets.first_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.buckets.second_filter.doc_count: 1 } | ||
- match: { aggregations.the_filter.meta.foo: "bar" } | ||
|
||
--- | ||
"Bad params": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_filter: | ||
filters: | ||
filters: [] | ||
|