Phase 4: Use grouping_missing_value_placeholder in aggregation logic - #895
Conversation
|
To test this out and provide examples I used the demo app and modified the factory to generate some null values for fields of albums: GraphQL Query with a subaggregation grouping by a single fieldFirst is an example that groups by a single fie.d GraphQL query resultsES/OS query with missing bucket aggregation (without this PR)Note there are two aggregations, ES/OS query using missing value (with this PR)Note there is only a single aggregation, GraphQL query grouping by two fieldsGraphQL query resultsES/OS query with missing bucket aggregations (without this PR).Note the nested permutations. ES/OS query using missing value (with this PR)Note there are fewer aggregations. |
|
This example shows that ElasticSearch/OpenSearch support NaN as a missing value for numeric fields in terms aggregations. In this case, the albums.soldUnits field has a mapping type of I ran these queries on both ElasticSearch and OpenSearch. Here is the query results If I try to remove the quotes around NaN like this: I get this error (unsurprisingly, since that isn't valid JSON): If I try to use And if I try to use And if I try A number as a string works and results in a number (not as a string) in the response bucket. With I get the same results as above when using |
This commit refactors the grouping logic to use the grouping_missing_value_placeholder from types, falling back to separate missing aggregations when no placeholder is defined. Backward compatibility: - When no placeholder is defined (returns nil), falls back to the old approach of creating separate missing aggregations - This ensures existing behavior is preserved for types without placeholders
61eeb79 to
f7ece77
Compare
762343b to
3274a96
Compare
3274a96 to
83c5eb7
Compare
This commit refactors the grouping logic to use the grouping_missing_value_placeholder from types, falling back to separate missing aggregations when no placeholder is defined. Backward compatibility: - When no placeholder is defined (returns nil), falls back to the old approach of creating separate missing aggregations - This ensures existing behavior is preserved for types without placeholders
83c5eb7 to
5781708
Compare
|
I believe I've addressed all comments. Since this is the only PR in this series that actually changes query behavior, I'm OK if we hold off on merging it until we've been able to deploy in a staging environment to verify it improves performance without introducing issues. |


This is 4th in a series of new pull requests that are working toward a new approach to handling missing values in subaggregations as described in #882. For an outline of the steps see the comment from @myronmarston here.
This commit refactors the grouping logic to use the grouping_missing_value_placeholder from types, falling back to separate missing aggregations when no placeholder is defined.
Backward compatibility:
Other PRs
Note PRs after the first one are on my fork since I don't currently have permissions to push to the block/elasticgraph repo (so I couldn't create stacked PRs on the block repo that are based on the branch from the prior PR).
Phase 1: Add grouping_missing_value_placeholder runtime metadata
Phase 2: Infer grouping_missing_value_placeholder based on mapping_type
Phase 3: Wire up grouping_missing_value_placeholder in GraphQL layer
Phase 4: Use grouping_missing_value_placeholder in aggregation logic (this PR)