rest-api-spec.test.search.aggregation.280_rare_terms.yml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-api-spec Show documentation
Show all versions of rest-api-spec Show documentation
OpenSearch subproject :rest-api-spec
The newest version!
setup:
- skip:
version: " - 7.2.99"
reason: RareTerms added in 7.3.0
- do:
indices.create:
index: test_1
body:
settings:
number_of_replicas: 0
mappings:
properties:
str:
type: keyword
ip:
type: ip
boolean:
type: boolean
integer:
type: long
number:
type: long
date:
type: date
- do:
cluster.health:
wait_for_status: green
---
"Basic test":
- do:
index:
index: test_1
id: 1
body: { "str" : "abc" }
- do:
index:
index: test_1
id: 2
body: { "str": "abc" }
- do:
index:
index: test_1
id: 3
body: { "str": "bcd" }
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "str_terms" : { "rare_terms" : { "field" : "str", "max_doc_count" : 1 } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.str_terms.buckets: 1 }
- match: { aggregations.str_terms.buckets.0.key: "bcd" }
- is_false: aggregations.str_terms.buckets.0.key_as_string
- match: { aggregations.str_terms.buckets.0.doc_count: 1 }
---
"IP test":
- do:
index:
index: test_1
id: 1
body: { "ip": "::1" }
- do:
index:
index: test_1
id: 2
body: { "ip": "127.0.0.1" }
- do:
index:
index: test_1
id: 3
body: { "ip": "::1" }
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "ip_terms" : { "rare_terms" : { "field" : "ip" } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.ip_terms.buckets: 1 }
- match: { aggregations.ip_terms.buckets.0.key: "127.0.0.1" }
- is_false: aggregations.ip_terms.buckets.0.key_as_string
- match: { aggregations.ip_terms.buckets.0.doc_count: 1 }
- do:
search:
body: { "size" : 0, "aggs" : { "ip_terms" : { "rare_terms" : { "field" : "ip", "include" : [ "127.0.0.1" ] } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.ip_terms.buckets: 1 }
- match: { aggregations.ip_terms.buckets.0.key: "127.0.0.1" }
- is_false: aggregations.ip_terms.buckets.0.key_as_string
- match: { aggregations.ip_terms.buckets.0.doc_count: 1 }
- do:
search:
body: { "size" : 0, "aggs" : { "ip_terms" : { "rare_terms" : { "field" : "ip", "exclude" : [ "127.0.0.1" ] } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.ip_terms.buckets: 0 }
- do:
catch: /Aggregation \[ip_terms\] cannot support regular expression style include\/exclude settings as they can only be applied to string fields\. Use an array of values for include\/exclude clauses/
search:
index: test_1
body: { "size" : 0, "aggs" : { "ip_terms" : { "rare_terms" : { "field" : "ip", "exclude" : "127.*" } } } }
---
"Boolean test":
- do:
index:
index: test_1
id: 1
body: { "boolean": true }
- do:
index:
index: test_1
id: 2
body: { "boolean": false }
- do:
index:
index: test_1
id: 3
body: { "boolean": true }
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "boolean_terms" : { "rare_terms" : { "field" : "boolean" } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.boolean_terms.buckets: 1 }
- match: { aggregations.boolean_terms.buckets.0.key: 0 }
- match: { aggregations.boolean_terms.buckets.0.key_as_string: "false" }
- match: { aggregations.boolean_terms.buckets.0.doc_count: 1 }
---
"Integer test":
- do:
index:
index: test_1
id: 1
body: { "integer": 1234 }
- do:
index:
index: test_1
id: 2
body: { "integer": 5678 }
- do:
index:
index: test_1
id: 3
body: { "integer": 1234 }
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "integer_terms" : { "rare_terms" : { "field" : "integer" } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.integer_terms.buckets: 1 }
- match: { aggregations.integer_terms.buckets.0.key: 5678 }
- is_false: aggregations.integer_terms.buckets.0.key_as_string
- match: { aggregations.integer_terms.buckets.0.doc_count: 1 }
---
"Date test":
- do:
index:
index: test_1
id: 1
body: { "date": "2016-05-03" }
- do:
index:
index: test_1
id: 2
body: { "date": "2014-09-01" }
- do:
index:
index: test_1
id: 3
body: { "date": "2016-05-03" }
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "date_terms" : { "rare_terms" : { "field" : "date" } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.date_terms.buckets: 1 }
- match: { aggregations.date_terms.buckets.0.key: 1409529600000 }
- match: { aggregations.date_terms.buckets.0.key_as_string: "2014-09-01T00:00:00.000Z" }
- match: { aggregations.date_terms.buckets.0.doc_count: 1 }
- do:
search:
body: { "size" : 0, "aggs" : { "date_terms" : { "rare_terms" : { "field" : "date", "include" : [ "2014-09-01" ] } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.date_terms.buckets: 1 }
- match: { aggregations.date_terms.buckets.0.key_as_string: "2014-09-01T00:00:00.000Z" }
- match: { aggregations.date_terms.buckets.0.doc_count: 1 }
- do:
search:
body: { "size" : 0, "aggs" : { "date_terms" : { "rare_terms" : { "field" : "date", "exclude" : [ "2014-09-01" ] } } } }
- match: { hits.total.value: 3 }
- length: { aggregations.date_terms.buckets: 0 }
---
"Unmapped strings":
- do:
index:
index: test_1
id: 1
body: {}
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "string_terms" : { "rare_terms" : { "field" : "unmapped_string"} } } }
- match: { hits.total.value: 1 }
- length: { aggregations.string_terms.buckets: 0 }
---
"Unmapped booleans":
- do:
index:
index: test_1
id: 1
body: {}
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "boolean_terms" : { "rare_terms" : { "field" : "unmapped_boolean" } } } }
- match: { hits.total.value: 1 }
- length: { aggregations.boolean_terms.buckets: 0 }
---
"Unmapped dates":
- do:
index:
index: test_1
id: 1
body: {}
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "date_terms" : { "rare_terms" : { "field" : "unmapped_date"} } } }
- match: { hits.total.value: 1 }
- length: { aggregations.date_terms.buckets: 0 }
---
"Unmapped longs":
- do:
index:
index: test_1
id: 1
body: {}
- do:
indices.refresh: {}
- do:
search:
body: { "size" : 0, "aggs" : { "long_terms" : { "rare_terms" : { "field" : "unmapped_long", "value_type" : "long" } } } }
- match: { hits.total.value: 1 }
- length: { aggregations.long_terms.buckets: 0 }
---
"sub aggs":
- skip:
version: " - 7.6.1"
reason: Sub aggs fixed in 7.6.1
- do:
index:
refresh: true
index: test_1
id: 1
body: { "str" : "abc", "number": 1 }
- do:
index:
refresh: true
index: test_1
id: 2
body: { "str": "abc", "number": 2 }
- do:
index:
refresh: true
index: test_1
id: 3
body: { "str": "bcd", "number": 3 }
- do:
search:
body:
size: 0
aggs:
str_terms:
rare_terms:
field: str
max_doc_count: 1
aggs:
max_n:
max:
field: number
- match: { hits.total.value: 3 }
- length: { aggregations.str_terms.buckets: 1 }
- match: { aggregations.str_terms.buckets.0.key: "bcd" }
- is_false: aggregations.str_terms.buckets.0.key_as_string
- match: { aggregations.str_terms.buckets.0.doc_count: 1 }
- match: { aggregations.str_terms.buckets.0.max_n.value: 3.0 }
---
"avg_bucket":
- skip:
version: " - 7.7.99"
reason: Fixed in 7.8.0
- do:
indices.create:
index: test
body:
settings:
number_of_replicas: 0
mappings:
properties:
str:
type: keyword
- do:
bulk:
index: test
refresh: true
body:
- '{"index": {}}'
- '{"str": "foo", "v": 1}'
- '{"index": {}}'
- '{"str": "foo", "v": 2}'
- '{"index": {}}'
- '{"str": "foo", "v": 3}'
- '{"index": {}}'
- '{"str": "bar", "v": 4}'
- '{"index": {}}'
- '{"str": "bar", "v": 5}'
- '{"index": {}}'
- '{"str": "baz", "v": 6}'
- do:
search:
index: test
body:
size: 0
aggs:
str_terms:
rare_terms:
field: str
max_doc_count: 2
aggs:
v:
sum:
field: v
str_terms_avg_v:
avg_bucket:
buckets_path: str_terms.v
- match: { hits.total.value: 6 }
- length: { aggregations.str_terms.buckets: 2 }
- match: { aggregations.str_terms.buckets.0.key: baz }
- match: { aggregations.str_terms.buckets.0.doc_count: 1 }
- match: { aggregations.str_terms.buckets.0.v.value: 6 }
- match: { aggregations.str_terms.buckets.1.key: bar }
- match: { aggregations.str_terms.buckets.1.doc_count: 2 }
- match: { aggregations.str_terms.buckets.1.v.value: 9 }
- match: { aggregations.str_terms_avg_v.value: 7.5 }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy