-
-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for keyed parameter in range and histgram aggregations #1424
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use with_capacity here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed! 80a1418
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🙏 |
src/aggregation/agg_req.rs
Outdated
@@ -36,7 +37,8 @@ | |||
//! "ranges": [ | |||
//! { "from": 3.0, "to": 7.0 }, | |||
//! { "from": 7.0, "to": 20.0 } | |||
//! ] | |||
//! ], | |||
//! "keyed": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the default, I think we can just omit it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 6444516
src/aggregation/mod.rs
Outdated
@@ -881,7 +891,8 @@ mod tests { | |||
{ "from": 7.0, "to": 19.0 }, | |||
{ "from": 19.0, "to": 20.0 }, | |||
{ "from": 20.0 } | |||
] | |||
], | |||
"keyed": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to add this? the default behaviour should be the same
@@ -132,6 +132,7 @@ | |||
//! 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! keyed: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay there's no ..Default::default
, we can keep it here
src/aggregation/mod.rs
Outdated
}, | ||
"aggs": { | ||
"bucketsL2": { | ||
"histogram": { | ||
"field": "score", | ||
"interval": 70.0 | ||
"interval": 70.0, | ||
"keyed": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"keyed": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry missed those, fixed in 9b6b60c
src/aggregation/mod.rs
Outdated
@@ -536,7 +541,8 @@ mod tests { | |||
"bucketsL2": { | |||
"histogram": { | |||
"field": "score", | |||
"interval": 70.0 | |||
"interval": 70.0, | |||
"keyed": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"keyed": false |
Resolves #1336
This PR adds support for
keyed
parameter in range and histogram aggregations in the same way elasticsearch does.