mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-23 19:50:42 +00:00
return Option from as_ methods
This commit is contained in:
@@ -100,16 +100,16 @@ pub(crate) struct BucketAggregationInternal {
|
||||
}
|
||||
|
||||
impl BucketAggregationInternal {
|
||||
pub(crate) fn as_histogram(&self) -> &HistogramAggregation {
|
||||
pub(crate) fn as_histogram(&self) -> Option<&HistogramAggregation> {
|
||||
match &self.bucket_agg {
|
||||
BucketAggregationType::Histogram(histogram) => histogram,
|
||||
_ => panic!("unexpected aggregation"),
|
||||
BucketAggregationType::Histogram(histogram) => Some(histogram),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub(crate) fn as_term(&self) -> &TermsAggregation {
|
||||
pub(crate) fn as_term(&self) -> Option<&TermsAggregation> {
|
||||
match &self.bucket_agg {
|
||||
BucketAggregationType::Terms(terms) => terms,
|
||||
_ => panic!("unexpected aggregation"),
|
||||
BucketAggregationType::Terms(terms) => Some(terms),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,15 +179,16 @@ impl BucketResult {
|
||||
IntermediateBucketResult::Histogram { buckets } => {
|
||||
let buckets = intermediate_buckets_to_final_buckets(
|
||||
buckets,
|
||||
req.as_histogram(),
|
||||
req.as_histogram().expect("unexpected aggregation"),
|
||||
&req.sub_aggregation,
|
||||
);
|
||||
|
||||
BucketResult::Histogram { buckets }
|
||||
}
|
||||
IntermediateBucketResult::Terms(terms) => {
|
||||
terms.into_final_result(req.as_term(), &req.sub_aggregation)
|
||||
}
|
||||
IntermediateBucketResult::Terms(terms) => terms.into_final_result(
|
||||
req.as_term().expect("unexpected aggregation"),
|
||||
&req.sub_aggregation,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,9 @@ use crate::DocId;
|
||||
///
|
||||
/// # Limitations/Compatibility
|
||||
///
|
||||
/// Each segment returns up to [segment_size](TermsAggregation::segment_size) results. This
|
||||
/// differences to elasticsearch behaviour.
|
||||
///
|
||||
/// # Request JSON Format
|
||||
/// ```json
|
||||
/// {
|
||||
@@ -87,6 +90,8 @@ pub struct TermsAggregation {
|
||||
/// include doc_count_error_upper_bound, which is an upper bound to the error on the
|
||||
/// doc_count returned by each shard. It’s the sum of the size of the largest bucket on
|
||||
/// each segment that didn’t fit into `shard_size`.
|
||||
///
|
||||
/// Defaults to true.
|
||||
#[serde(default = "default_show_term_doc_count_error")]
|
||||
pub show_term_doc_count_error: bool,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user