Add support for keyed parameter in range and histgram aggregations#1424
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1424 +/- ##
==========================================
+ Coverage 94.22% 94.23% +0.01%
==========================================
Files 236 236
Lines 43775 43898 +123
==========================================
+ Hits 41245 41367 +122
- Misses 2530 2531 +1
Continue to review full report at Codecov.
|
3f623df to
53097ab
Compare
53097ab to
d122f2c
Compare
| .keyed | ||
| .is_some(); | ||
| let buckets = if is_keyed { | ||
| let mut bucket_map = HashMap::new(); |
There was a problem hiding this comment.
we can use with_capacity here
|
Awesome thank you! GET sales/_search
{
"aggs": {
"price_ranges": {
"range": {
"field": "price",
"keyed": true,
"ranges": [
{ "key": "cheap", "to": 100 },
{ "key": "average", "from": 100, "to": 200 },
{ "key": "expensive", "from": 200 }
]
}
}
}
}
|
|
@PSeitz |
|
@PSeitz If so, it would be great if we could have a separate issue🙏 |
| //! { "from": 7.0, "to": 20.0 } | ||
| //! ] | ||
| //! ], | ||
| //! "keyed": false |
There was a problem hiding this comment.
this is the default, I think we can just omit it
There was a problem hiding this comment.
It didn't pass the tests...
https://github.com/quickwit-oss/tantivy/runs/7517376126?check_suite_focus=true
Ah I see, I removed serde(default) by mistake, let me fix
| { "from": 20.0 } | ||
| ] | ||
| ], | ||
| "keyed": false |
There was a problem hiding this comment.
do we have to add this? the default behaviour should be the same
| //! bucket_agg: BucketAggregationType::Range(RangeAggregation{ | ||
| //! field: "score".to_string(), | ||
| //! ranges: vec![(3f64..7f64).into(), (7f64..20f64).into()], | ||
| //! keyed: false, |
There was a problem hiding this comment.
| //! keyed: false, |
There was a problem hiding this comment.
@PSeitz
Could we do that?
Just removing the field will cause compiler error.
missing field `keyed` in initializer of `RangeAggregation`
There was a problem hiding this comment.
ah okay there's no ..Default::default, we can keep it here
| "field": "score", | ||
| "interval": 70.0 | ||
| "interval": 70.0, | ||
| "keyed": false |
There was a problem hiding this comment.
| "keyed": false |
| "field": "score", | ||
| "interval": 70.0 | ||
| "interval": 70.0, | ||
| "keyed": false |
There was a problem hiding this comment.
| "keyed": false |
Resolves #1336
This PR adds support for
keyedparameter in range and histogram aggregations in the same way elasticsearch does.