From 2de6f075ce27f83e6b9da72359f0a3a2a4e04237 Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Thu, 15 Jan 2026 15:51:43 -1000 Subject: [PATCH] Fixed the example --- src/aggregation/agg_req.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/aggregation/agg_req.rs b/src/aggregation/agg_req.rs index dc1a86b4f..8b021b656 100644 --- a/src/aggregation/agg_req.rs +++ b/src/aggregation/agg_req.rs @@ -124,9 +124,21 @@ pub fn get_fast_field_names(aggs: &Aggregations) -> HashSet { /// # Example /// ``` /// use tantivy::aggregation::agg_req::{Aggregations, validate_aggregation_fields}; +/// use tantivy::schema::{Schema, FAST}; /// use tantivy::Index; /// -/// # fn example(index: &Index, agg_req: Aggregations) -> tantivy::Result<()> { +/// # fn main() -> tantivy::Result<()> { +/// // Create a simple index +/// let mut schema_builder = Schema::builder(); +/// schema_builder.add_f64_field("price", FAST); +/// let schema = schema_builder.build(); +/// let index = Index::create_in_ram(schema); +/// +/// // Parse aggregation request +/// let agg_req: Aggregations = serde_json::from_str(r#"{ +/// "avg_price": { "avg": { "field": "price" } } +/// }"#)?; +/// /// let reader = index.reader()?; /// let searcher = reader.searcher(); ///