OpenSearch/rest-api-spec/test/search.aggregation/10_histogram.yaml

144 lines
3.1 KiB
YAML

setup:
- do:
indices.create:
index: test_1
body:
mappings:
test:
"properties":
"number":
"type" : "integer"
- do:
cluster.health:
wait_for_status: green
---
"Basic test":
- do:
index:
index: test_1
type: test
id: 1
body: { "number" : 1 }
- do:
index:
index: test_1
type: test
id: 2
body: { "number" : 51 }
- do:
index:
index: test_1
type: test
id: 3
body: { "number" : 101 }
- do:
index:
index: test_1
type: test
id: 4
body: { "number" : 151 }
- do:
indices.refresh: {}
- do:
search:
body: { "aggs" : { "histo" : { "histogram" : { "field" : "number", "interval" : 50 } } } }
- match: { hits.total: 4 }
- length: { aggregations.histo.buckets: 4 }
- match: { aggregations.histo.buckets.0.key: 0 }
- is_false: aggregations.histo.buckets.0.key_as_string
- match: { aggregations.histo.buckets.0.doc_count: 1 }
- match: { aggregations.histo.buckets.1.key: 50 }
- is_false: aggregations.histo.buckets.1.key_as_string
- match: { aggregations.histo.buckets.1.doc_count: 1 }
- match: { aggregations.histo.buckets.2.key: 100 }
- is_false: aggregations.histo.buckets.2.key_as_string
- match: { aggregations.histo.buckets.2.doc_count: 1 }
- match: { aggregations.histo.buckets.3.key: 150 }
- is_false: aggregations.histo.buckets.3.key_as_string
- match: { aggregations.histo.buckets.3.doc_count: 1 }
---
"Format test":
- do:
index:
index: test_1
type: test
id: 1
body: { "number" : 1 }
- do:
index:
index: test_1
type: test
id: 2
body: { "number" : 51 }
- do:
index:
index: test_1
type: test
id: 3
body: { "number" : 101 }
- do:
index:
index: test_1
type: test
id: 4
body: { "number" : 151 }
- do:
indices.refresh: {}
- do:
search:
body: { "aggs" : { "histo" : { "histogram" : { "field" : "number", "interval" : 50, "format" : "Value is ##0.0" } } } }
- match: { hits.total: 4 }
- length: { aggregations.histo.buckets: 4 }
- match: { aggregations.histo.buckets.0.key: 0 }
- match: { aggregations.histo.buckets.0.key_as_string: "Value is 0.0" }
- match: { aggregations.histo.buckets.0.doc_count: 1 }
- match: { aggregations.histo.buckets.1.key: 50 }
- match: { aggregations.histo.buckets.1.key_as_string: "Value is 50.0" }
- match: { aggregations.histo.buckets.1.doc_count: 1 }
- match: { aggregations.histo.buckets.2.key: 100 }
- match: { aggregations.histo.buckets.2.key_as_string: "Value is 100.0" }
- match: { aggregations.histo.buckets.2.doc_count: 1 }
- match: { aggregations.histo.buckets.3.key: 150 }
- match: { aggregations.histo.buckets.3.key_as_string: "Value is 150.0" }
- match: { aggregations.histo.buckets.3.doc_count: 1 }