Skip to content

Conversation

@mdashti
Copy link
Contributor

@mdashti mdashti commented Nov 18, 2025

What

Fixed deserialization of nested aggregations when the aggs field is embedded inside an aggregation variant's configuration object.

Why

Previously, aggregation requests with nested aggs like {"terms": {"field": "category", "aggs": {...}}} failed to deserialize correctly. The nested aggregations were being ignored because the deserializer expected aggs at the top level, not inside the aggregation variant's config.

How

Modified the TryFrom<AggregationForDeserialization> implementation to:

  1. Scan the aggregation config object for nested aggs fields
  2. Extract and parse them as sub-aggregations before deserializing the main variant
  3. Assign the extracted nested aggregations to the sub_aggregation field

The implementation uses a functional approach to find and extract the first nested aggs field from the aggregation configuration.

Tests

Added three test cases covering:

  • Basic nested aggregations (terms → terms)
  • Triple-nested aggregations (terms → terms → terms)
  • Nested aggregations with metric sub-aggregations (terms → avg/max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant