From 938bfec8b79ce79b06806a5d7b627634b911ab55 Mon Sep 17 00:00:00 2001 From: PSeitz Date: Tue, 21 Oct 2025 15:59:18 +0200 Subject: [PATCH] use FxHashMap for Aggregations Request (#2722) Co-authored-by: Pascal Seitz --- src/aggregation/agg_req.rs | 5 +++-- src/aggregation/bucket/term_agg.rs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/aggregation/agg_req.rs b/src/aggregation/agg_req.rs index e2a85c8fb..e5dfed85a 100644 --- a/src/aggregation/agg_req.rs +++ b/src/aggregation/agg_req.rs @@ -26,8 +26,9 @@ //! let _agg_req: Aggregations = serde_json::from_str(elasticsearch_compatible_json_req).unwrap(); //! ``` -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use super::bucket::{ @@ -43,7 +44,7 @@ use super::metric::{ /// defined names. It is also used in buckets aggregations to define sub-aggregations. /// /// The key is the user defined name of the aggregation. -pub type Aggregations = HashMap; +pub type Aggregations = FxHashMap; /// Aggregation request. /// diff --git a/src/aggregation/bucket/term_agg.rs b/src/aggregation/bucket/term_agg.rs index 92b9a5886..88712a2af 100644 --- a/src/aggregation/bucket/term_agg.rs +++ b/src/aggregation/bucket/term_agg.rs @@ -2362,7 +2362,8 @@ mod tests { let mut agg_res = search(&index, &agg_req)?; // --- Aggregations: terms on host and tags --- - let mut agg_req2: Aggregations = Aggregations::with_capacity(20); + let mut agg_req2: Aggregations = + Aggregations::with_capacity_and_hasher(20, Default::default()); agg_req2.insert( "tags".to_string(), serde_json::from_value(json!({ "terms": { "field": "tags" } }))?,