Skip to content

Commit cbd689b

Browse files
anandheritageAnand Kumar Shaw
authored andcommitted
[Star Tree] Add date dimension support for range aggregation validation
This change extends the star-tree range aggregation validation to support DateDimension in addition to NumericDimension. Previously, range aggregations with star-tree optimization only worked with numeric fields. Now date fields can also leverage star-tree indexes for range aggregations. Signed-off-by: Anand Kumar Shaw <anandkrshawheritage@gmail.com>
1 parent a7c85f2 commit cbd689b

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616
- Add index-level-encryption support for snapshots and remote-store ([#20095](https://github.com/opensearch-project/OpenSearch/pull/20095))
1717
- Adding BackWardCompatibility test for remote publication enabled cluster ([#20221](https://github.com/opensearch-project/OpenSearch/pull/20221))
1818
- Support for hll field mapper to support cardinality rollups ([#20129](https://github.com/opensearch-project/OpenSearch/pull/20129))
19+
- Expand fetch phase profiling to support inner hits and top hits aggregation phases ([##18936](https://github.com/opensearch-project/OpenSearch/pull/18936))
20+
- Add temporal routing processors for time-based document routing ([#18920](https://github.com/opensearch-project/OpenSearch/issues/18920))
21+
- Implement Query Rewriting Infrastructure ([#19060](https://github.com/opensearch-project/OpenSearch/pull/19060))
22+
- The dynamic mapping parameter supports false_allow_templates ([#19065](https://github.com/opensearch-project/OpenSearch/pull/19065))
23+
- Add a toBuilder method in EngineConfig to support easy modification of configs([#19054](https://github.com/opensearch-project/OpenSearch/pull/19054))
24+
- Add StoreFactory plugin interface for custom Store implementations([#19091](https://github.com/opensearch-project/OpenSearch/pull/19091))
25+
- Use S3CrtClient for higher throughput while uploading files to S3 ([#18800](https://github.com/opensearch-project/OpenSearch/pull/18800))
26+
- Add a dynamic setting to change skip_cache_factor and min_frequency for querycache ([#18351](https://github.com/opensearch-project/OpenSearch/issues/18351))
27+
- Add overload constructor for Translog to accept Channel Factory as a parameter ([#18918](https://github.com/opensearch-project/OpenSearch/pull/18918))
28+
- Add subdirectory-aware store module with recovery support ([#19132](https://github.com/opensearch-project/OpenSearch/pull/19132))
29+
- [Star Tree] Add support for date type dimensions in range aggregation validation ([#20460](https://github.com/opensearch-project/OpenSearch/pull/20460))
1930

2031
### Changed
2132
- Handle custom metadata files in subdirectory-store ([#20157](https://github.com/opensearch-project/OpenSearch/pull/20157))

server/src/main/java/org/opensearch/search/startree/StarTreeQueryContext.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ private static boolean validateRangeAggregationSupport(
165165
CompositeDataCubeFieldType compositeIndexFieldInfo,
166166
RangeAggregatorFactory rangeAggregatorFactory
167167
) {
168-
// Validate request field is part of dimensions & is a numeric field
169-
// TODO: Add support for date type ranges
168+
// Validate request field is part of dimensions & is a numeric or date field
170169
return compositeIndexFieldInfo.getDimensions()
171170
.stream()
172-
.anyMatch(dimension -> rangeAggregatorFactory.getField().equals(dimension.getField()) && dimension instanceof NumericDimension);
171+
.anyMatch(
172+
dimension -> rangeAggregatorFactory.getField().equals(dimension.getField())
173+
&& (dimension instanceof NumericDimension || dimension instanceof DateDimension)
174+
);
173175
}
174176

175177
private StarTreeFilter getStarTreeFilter(

server/src/test/java/org/opensearch/search/SearchServiceStarTreeTests.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,11 +914,33 @@ public void testQueryParsingForRangeAggregations() throws IOException {
914914
sourceBuilder = new SearchSourceBuilder().size(0).query(baseQuery).aggregation(rangeAggregationBuilder);
915915
assertStarTreeContext(request, sourceBuilder, null, -1);
916916

917-
// Case 6: Range Aggregation on non-numeric field, should not use star tree
917+
// Case 6: Range Aggregation on date field with DateDimension in star-tree, should use star tree
918918
rangeAggregationBuilder = range("range").field(TIMESTAMP_FIELD).addRange(0, 100).subAggregation(maxAggNoSub);
919919
baseQuery = new MatchAllQueryBuilder();
920920
sourceBuilder = new SearchSourceBuilder().size(0).query(baseQuery).aggregation(rangeAggregationBuilder);
921-
assertStarTreeContext(request, sourceBuilder, null, -1);
921+
assertStarTreeContext(
922+
request,
923+
sourceBuilder,
924+
getStarTreeQueryContext(
925+
searchContext,
926+
starTreeFieldConfiguration,
927+
"startree1",
928+
-1,
929+
List.of(
930+
new DateDimension(
931+
TIMESTAMP_FIELD,
932+
List.of(new DateTimeUnitAdapter(Rounding.DateTimeUnit.MONTH_OF_YEAR)),
933+
DateFieldMapper.Resolution.MILLISECONDS
934+
),
935+
new OrdinalDimension(KEYWORD_FIELD)
936+
),
937+
List.of(new Metric(STATUS, List.of(MetricStat.SUM, MetricStat.MAX))),
938+
baseQuery,
939+
sourceBuilder,
940+
true
941+
),
942+
-1
943+
);
922944

923945
// Case 7: Valid range aggregation and valid metric aggregation, should use star tree & cache
924946
rangeAggregationBuilder = range("range").field(NUMERIC_FIELD).addRange(0, 100).subAggregation(maxAggNoSub);

0 commit comments

Comments
 (0)