Skip to content

Commit

Permalink
added test for flattened type in top_metrics.yml (#78960) (#79368)
Browse files Browse the repository at this point in the history
Co-authored-by: Nilanshu V Rajmane <rajmanenilanshu@gmail.com>
  • Loading branch information
nik9000 and nilanshu96 authored Oct 18, 2021
1 parent 7490958 commit 171ae21
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,42 @@
- match: { aggregations.tm.top.1.sort: [2] }
- match: { aggregations.tm.top.2.metrics.animal\.keyword: null}
- match: { aggregations.tm.top.2.sort: [3] }

---
"with flattened":
- do:
indices.create:
index: test
body:
mappings:
properties:
host:
type: flattened

- do:
bulk:
index: test
refresh: true
body:
- '{"index": {}}'
- '{"host": {"hostname": "abc", "name": "x"}, "v": 1}'
- '{"index": {}}'
- '{"host": {"hostname": "foo", "name": "y"}, "v": 2}'
- '{"index": {}}'
- '{"host": {"hostname": "bar", "name": "z"}, "v": 3}'

- do:
search:
index: test
size: 0
body:
aggs:
tm:
top_metrics:
metrics:
field: host.hostname
sort:
v: asc
size: 3
- match: { aggregations.tm.top.0.sort: [1] }
- match: { aggregations.tm.top.0.metrics.host\.hostname: abc }

0 comments on commit 171ae21

Please sign in to comment.