Skip to content

Commit

Permalink
fix range agg docs
Browse files Browse the repository at this point in the history
fix range agg docs closes #3889
add range rest api test
add histogram rest api test
  • Loading branch information
PSeitz committed Sep 28, 2023
1 parent 46e65f8 commit 00a1c7b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 15 deletions.
16 changes: 9 additions & 7 deletions docs/reference/aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,15 @@ Overlapping ranges are not yet supported.
"max_hits": 0,
"aggs": {
"my_scores": {
"field": "score",
"ranges": [
{ "to": 3.0, "key": "low" },
{ "from": 3.0, "to": 7.0, "key": "medium-low" },
{ "from": 7.0, "to": 20.0, "key": "medium-high" },
{ "from": 20.0, "key": "high" }
]
"range": {
"field": "score",
"ranges": [
{ "to": 3.0, "key": "low" },
{ "from": 3.0, "to": 7.0, "key": "medium-low" },
{ "from": 7.0, "to": 20.0, "key": "medium-high" },
{ "from": 20.0, "key": "high" }
]
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
query: { match_all: {} }
aggs:
date_histo:
date_histogram:
Expand All @@ -25,8 +24,7 @@ engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
query: { match_all: {} }
aggs:
date_histo:
date_histogram:
Expand Down Expand Up @@ -72,14 +70,36 @@ expected:
- { "doc_count": 3, "key": 1420070400000.0, "key_as_string": "2015-01-01T00:00:00Z", "response": { "avg": 80.0, "count": 3, "max": 120.0, "min": 20.0, "sum": 240.0 } }
- { "doc_count": 2, "key": 1422662400000.0, "key_as_string": "2015-01-31T00:00:00Z", "response": { "avg": 80.0, "count": 2, "max": 130.0, "min": 30.0, "sum": 160.0 } }
---
# Test range aggregation
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query: { match_all: {} }
aggs:
my_range:
range:
field: response
ranges:
- { to: 50, key: fast }
- { from: 50, to: 80, key: medium }
- { from: 80, key: slow }
expected:
aggregations:
my_range:
buckets:
- { "doc_count": 4, "key": "fast", "to": 50.0 }
- { "doc_count": 0, "from": 50.0, "key": "medium", "to": 80.0 }
- { "doc_count": 3, "from": 80.0, "key": "slow" }
---
# Test term aggs
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
query: { match_all: {} }
aggs:
hosts:
terms:
Expand Down Expand Up @@ -116,8 +136,7 @@ engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query:
match_all: {}
query: { match_all: {} }
aggs:
metrics:
date_histogram:
Expand Down Expand Up @@ -149,3 +168,27 @@ expected:
values:
- key: 85.0
value: 30.26717133872237
---
# Test histogram
method: [GET]
engines:
- quickwit
endpoint: _elastic/aggregations/_search
json:
query: { match_all: {} }
aggs:
metrics:
histogram:
field: response
interval: 50
expected:
aggregations:
metrics:
buckets:
- doc_count: 4
key: 0.0
- doc_count: 0
key: 50.0
- doc_count: 3
key: 100.0

0 comments on commit 00a1c7b

Please sign in to comment.