From fdb2524f9e2dad870f9aeadaf24af032bfb5c82b Mon Sep 17 00:00:00 2001 From: Pascal Seitz Date: Sat, 30 Apr 2022 21:05:00 +0800 Subject: [PATCH] minor docs fixes --- src/aggregation/bucket/histogram/histogram.rs | 27 +++++++++++++++---- src/aggregation/bucket/range.rs | 2 +- src/aggregation/metric/average.rs | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/aggregation/bucket/histogram/histogram.rs b/src/aggregation/bucket/histogram/histogram.rs index cf7924bca..79015072e 100644 --- a/src/aggregation/bucket/histogram/histogram.rs +++ b/src/aggregation/bucket/histogram/histogram.rs @@ -56,7 +56,7 @@ use crate::{DocId, TantivyError}; /// "prices": { /// "histogram": { /// "field": "price", -/// "interval": 10, +/// "interval": 10 /// } /// } /// } @@ -69,16 +69,17 @@ use crate::{DocId, TantivyError}; pub struct HistogramAggregation { /// The field to aggregate on. pub field: String, - /// The interval to chunk your data range. The buckets span ranges of [0..interval). + /// The interval to chunk your data range. Each bucket spans a value range of [0..interval). /// Must be a positive value. pub interval: f64, /// Intervals implicitely defines an absolute grid of buckets `[interval * k, interval * (k + /// 1))`. /// - /// Offset makes it possible to shift this grid into `[offset + interval * k, offset + interval - /// * (k + 1)) Offset has to be in the range [0, interval). + /// Offset makes it possible to shift this grid into + /// `[offset + interval * k, offset + interval * (k + 1))`. Offset has to be in the range [0, + /// interval). /// - /// As an example. If there are two documents with value 8 and 12 and interval 10.0, they would + /// As an example, if there are two documents with value 9 and 12 and interval 10.0, they would /// fall into the buckets with the key 0 and 10. /// With offset 5 and interval 10, they would both fall into the bucket with they key 5 and the /// range [5..15) @@ -91,6 +92,22 @@ pub struct HistogramAggregation { /// /// hard_bounds only limits the buckets, to force a range set both extended_bounds and /// hard_bounds to the same range. + /// + /// ## Example + /// ```json + /// { + /// "prices": { + /// "histogram": { + /// "field": "price", + /// "interval": 10, + /// "hard_bounds": { + /// "min": 0, + /// "max": 100 + /// } + /// } + /// } + /// } + /// ``` pub hard_bounds: Option, /// Can be set to extend your bounds. The range of the buckets is by default defined by the /// data range of the values of the documents. As the name suggests, this can only be used to diff --git a/src/aggregation/bucket/range.rs b/src/aggregation/bucket/range.rs index c89b14ab0..d570e96a3 100644 --- a/src/aggregation/bucket/range.rs +++ b/src/aggregation/bucket/range.rs @@ -44,7 +44,7 @@ use crate::{DocId, TantivyError}; /// "ranges": [ /// { "to": 3.0 }, /// { "from": 3.0, "to": 7.0 }, -/// { "from": 7.0, "to": 20.0 } +/// { "from": 7.0, "to": 20.0 }, /// { "from": 20.0 } /// ] /// } diff --git a/src/aggregation/metric/average.rs b/src/aggregation/metric/average.rs index 69f353824..e5e5bb3f7 100644 --- a/src/aggregation/metric/average.rs +++ b/src/aggregation/metric/average.rs @@ -19,7 +19,7 @@ use crate::DocId; /// "avg": { /// "field": "score", /// } -/// } +/// } /// ``` pub struct AverageAggregation { /// The field name to compute the stats on.