Skip to content

Commit

Permalink
Add unit test case about multiple orders and size for multipler terms…
Browse files Browse the repository at this point in the history
… aggregation.
  • Loading branch information
zhikai-vmware committed Apr 27, 2024
1 parent f09ee2d commit f5a9520
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,3 +832,66 @@ setup:
- match: { aggregations.m_terms.buckets.3.doc_count: 2 }
- match: { aggregations.m_terms.buckets.3.max_int.value: 2.0 }
- match: { aggregations.m_terms.buckets.3.min_double.value: 1234.5 }

---
"multi_terms bucket and multiple orders with size test":
- skip:
version: "- 2.0.99"
reason: multi_terms aggregation is introduced in 2.1.0

- do:
bulk:
index: test_1
refresh: true
body:
- '{"index": {}}'
- '{"str": "a", "integer": 1, "double": 1234.5, "boolean": true}'
- '{"index": {}}'
- '{"str": "a", "integer": 2, "double": 5678.9, "boolean": true}'
- '{"index": {}}'
- '{"str": "a", "integer": 1, "double": 123.4, "boolean": false}'
- '{"index": {}}'
- '{"str": "a", "integer": 2, "double": 456.7, "boolean": false}'
- '{"index": {}}'
- '{"str": "b", "integer": 3, "double": 1234.5, "boolean": true}'
- '{"index": {}}'
- '{"str": "b", "integer": 4, "double": 5678.9, "boolean": true}'
- '{"index": {}}'
- '{"str": "b", "integer": 3, "double": 234.5, "boolean": false}'
- '{"index": {}}'
- '{"str": "b", "integer": 4, "double": 456.7, "boolean": false}'

- do:
search:
index: test_1
size: 0
body:
aggs:
m_terms:
multi_terms:
terms:
- field: str
- field: boolean
order:
- max_int: desc
- min_double: asc
size: 2
aggs:
max_int:
max:
field: integer
min_double:
min:
field: double

- length: { aggregations.m_terms.buckets: 2 }
- match: { aggregations.m_terms.buckets.0.key: ["b", false] }
- match: { aggregations.m_terms.buckets.0.key_as_string: "b|false" }
- match: { aggregations.m_terms.buckets.0.doc_count: 2 }
- match: { aggregations.m_terms.buckets.0.max_int.value: 4.0 }
- match: { aggregations.m_terms.buckets.0.min_double.value: 234.5 }
- match: { aggregations.m_terms.buckets.1.key: ["b", true] }
- match: { aggregations.m_terms.buckets.1.key_as_string: "b|true" }
- match: { aggregations.m_terms.buckets.1.doc_count: 2 }
- match: { aggregations.m_terms.buckets.1.max_int.value: 4.0 }
- match: { aggregations.m_terms.buckets.1.min_double.value: 1234.5 }

0 comments on commit f5a9520

Please sign in to comment.