mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-31 15:40:40 +00:00
Fix to use bool directory for the keyed parameter
This commit is contained in:
@@ -271,7 +271,7 @@ mod tests {
|
||||
(7f64..20f64).into(),
|
||||
(20f64..f64::MAX).into(),
|
||||
],
|
||||
keyed: Some(true),
|
||||
keyed: true,
|
||||
}),
|
||||
sub_aggregation: Default::default(),
|
||||
}),
|
||||
|
||||
@@ -48,8 +48,6 @@ use crate::{DocId, TantivyError};
|
||||
///
|
||||
/// # Limitations/Compatibility
|
||||
///
|
||||
/// The keyed parameter (elasticsearch) is not yet supported.
|
||||
///
|
||||
/// # JSON Format
|
||||
/// ```json
|
||||
/// {
|
||||
@@ -118,8 +116,7 @@ pub struct HistogramAggregation {
|
||||
/// bounds would not be returned.
|
||||
pub extended_bounds: Option<HistogramBounds>,
|
||||
/// Whether to return the buckets as a hash map
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub keyed: Option<bool>,
|
||||
pub keyed: bool,
|
||||
}
|
||||
|
||||
impl HistogramAggregation {
|
||||
@@ -1409,7 +1406,7 @@ mod tests {
|
||||
bucket_agg: BucketAggregationType::Histogram(HistogramAggregation {
|
||||
field: "score_f64".to_string(),
|
||||
interval: 50.0,
|
||||
keyed: Some(true),
|
||||
keyed: true,
|
||||
..Default::default()
|
||||
}),
|
||||
sub_aggregation: Default::default(),
|
||||
|
||||
@@ -57,8 +57,7 @@ pub struct RangeAggregation {
|
||||
/// range. Extra buckets will be created until the first to, and last from, if necessary.
|
||||
pub ranges: Vec<RangeAggregationRange>,
|
||||
/// Whether to return the buckets as a hash map
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub keyed: Option<bool>,
|
||||
pub keyed: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -467,7 +466,7 @@ mod tests {
|
||||
bucket_agg: BucketAggregationType::Range(RangeAggregation {
|
||||
field: "fraction_f64".to_string(),
|
||||
ranges: vec![(0f64..0.1f64).into(), (0.1f64..0.2f64).into()],
|
||||
keyed: Some(true),
|
||||
keyed: true,
|
||||
}),
|
||||
sub_aggregation: Default::default(),
|
||||
}),
|
||||
|
||||
@@ -285,8 +285,7 @@ impl IntermediateBucketResult {
|
||||
let is_keyed = req
|
||||
.as_range()
|
||||
.expect("unexpected aggregation, expected range aggregation")
|
||||
.keyed
|
||||
.is_some();
|
||||
.keyed;
|
||||
let buckets = if is_keyed {
|
||||
let mut bucket_map = HashMap::new();
|
||||
for bucket in buckets {
|
||||
@@ -306,7 +305,7 @@ impl IntermediateBucketResult {
|
||||
&req.sub_aggregation,
|
||||
)?;
|
||||
|
||||
let buckets = if req.as_histogram().unwrap().keyed.is_some() {
|
||||
let buckets = if req.as_histogram().unwrap().keyed {
|
||||
let mut bucket_map = HashMap::new();
|
||||
for bucket in buckets {
|
||||
bucket_map.insert(bucket.key.to_string(), bucket);
|
||||
|
||||
@@ -503,13 +503,15 @@ mod tests {
|
||||
"bucketsL1": {
|
||||
"range": {
|
||||
"field": "score",
|
||||
"ranges": [ { "to": 3.0f64 }, { "from": 3.0f64, "to": 70.0f64 }, { "from": 70.0f64 } ]
|
||||
"ranges": [ { "to": 3.0f64 }, { "from": 3.0f64, "to": 70.0f64 }, { "from": 70.0f64 } ],
|
||||
"keyed": false
|
||||
},
|
||||
"aggs": {
|
||||
"bucketsL2": {
|
||||
"range": {
|
||||
"field": "score",
|
||||
"ranges": [ { "to": 30.0f64 }, { "from": 30.0f64, "to": 70.0f64 }, { "from": 70.0f64 } ]
|
||||
"ranges": [ { "to": 30.0f64 }, { "from": 30.0f64, "to": 70.0f64 }, { "from": 70.0f64 } ],
|
||||
"keyed": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,12 +521,14 @@ mod tests {
|
||||
"field": "score",
|
||||
"interval": 70.0,
|
||||
"offset": 3.0,
|
||||
"keyed": false
|
||||
},
|
||||
"aggs": {
|
||||
"bucketsL2": {
|
||||
"histogram": {
|
||||
"field": "score",
|
||||
"interval": 70.0
|
||||
"interval": 70.0,
|
||||
"keyed": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,7 +541,8 @@ mod tests {
|
||||
"bucketsL2": {
|
||||
"histogram": {
|
||||
"field": "score",
|
||||
"interval": 70.0
|
||||
"interval": 70.0,
|
||||
"keyed": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -885,7 +890,8 @@ mod tests {
|
||||
{ "from": 7.0, "to": 19.0 },
|
||||
{ "from": 19.0, "to": 20.0 },
|
||||
{ "from": 20.0 }
|
||||
]
|
||||
],
|
||||
"keyed": false
|
||||
},
|
||||
"aggs": {
|
||||
"average_in_range": { "avg": { "field": "score" } },
|
||||
@@ -901,7 +907,8 @@ mod tests {
|
||||
{ "from": 7.0, "to": 19.0 },
|
||||
{ "from": 19.0, "to": 20.0 },
|
||||
{ "from": 20.0 }
|
||||
]
|
||||
],
|
||||
"keyed": false
|
||||
},
|
||||
"aggs": {
|
||||
"average_in_range": { "avg": { "field": "score" } },
|
||||
@@ -920,7 +927,8 @@ mod tests {
|
||||
{ "from": 7.0, "to": 19.0 },
|
||||
{ "from": 19.0, "to": 20.0 },
|
||||
{ "from": 20.0 }
|
||||
]
|
||||
],
|
||||
"keyed": false
|
||||
},
|
||||
"aggs": {
|
||||
"average_in_range": { "avg": { "field": "score" } },
|
||||
|
||||
Reference in New Issue
Block a user