Skip to content

Commit ed33488

Browse files
Support multi ranges traversal when doing date histogram rewrite optimization (opensearch-project#13317)
1 parent a8017d8 commit ed33488

File tree

11 files changed

+821
-144
lines changed

11 files changed

+821
-144
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3636
- [Remote Store] Upload remote paths during remote enabled index creation ([#13386](https://github.com/opensearch-project/OpenSearch/pull/13386))
3737
- [Search Pipeline] Handle default pipeline for multiple indices ([#13276](https://github.com/opensearch-project/OpenSearch/pull/13276))
3838
- Add support for deep copying SearchRequest ([#12295](https://github.com/opensearch-project/OpenSearch/pull/12295))
39+
- Support multi ranges traversal when doing date histogram rewrite optimization. ([#13317](https://github.com/opensearch-project/OpenSearch/pull/13317))
3940

4041
### Dependencies
4142
- Bump `org.apache.commons:commons-configuration2` from 2.10.0 to 2.10.1 ([#12896](https://github.com/opensearch-project/OpenSearch/pull/12896))

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yml

+56
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,59 @@ setup:
644644
- match: { aggregations.histo.buckets.0.doc_count: 1 }
645645
- match: { aggregations.histo.buckets.20.key: 20 }
646646
- match: { aggregations.histo.buckets.20.doc_count: 1 }
647+
648+
---
649+
"date_histogram profiler shows filter rewrite info":
650+
- skip:
651+
version: " - 2.99.99"
652+
reason: debug info for filter rewrite added in 3.0.0 (to be backported to 2.14.0)
653+
654+
- do:
655+
indices.create:
656+
index: test_2
657+
body:
658+
settings:
659+
number_of_replicas: 0
660+
number_of_shards: 1
661+
mappings:
662+
properties:
663+
date:
664+
type: date
665+
666+
- do:
667+
bulk:
668+
index: test_2
669+
refresh: true
670+
body:
671+
- '{"index": {}}'
672+
- '{"date": "2016-01-01"}'
673+
- '{"index": {}}'
674+
- '{"date": "2016-01-02"}'
675+
- '{"index": {}}'
676+
- '{"date": "2016-02-01"}'
677+
- '{"index": {}}'
678+
- '{"date": "2016-03-01"}'
679+
680+
- do:
681+
search:
682+
index: test_2
683+
body:
684+
size: 0
685+
profile: true
686+
aggs:
687+
histo:
688+
date_histogram:
689+
field: date
690+
calendar_interval: month
691+
692+
- match: { hits.total.value: 4 }
693+
- length: { aggregations.histo.buckets: 3 }
694+
- match: { aggregations.histo.buckets.0.key_as_string: "2016-01-01T00:00:00.000Z" }
695+
- match: { aggregations.histo.buckets.0.doc_count: 2 }
696+
- match: { profile.shards.0.aggregations.0.type: DateHistogramAggregator }
697+
- match: { profile.shards.0.aggregations.0.description: histo }
698+
- match: { profile.shards.0.aggregations.0.debug.total_buckets: 3 }
699+
- match: { profile.shards.0.aggregations.0.debug.optimized_segments: 1 }
700+
- match: { profile.shards.0.aggregations.0.debug.unoptimized_segments: 0 }
701+
- match: { profile.shards.0.aggregations.0.debug.leaf_visited: 1 }
702+
- match: { profile.shards.0.aggregations.0.debug.inner_visited: 0 }

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/230_composite.yml

+58
Original file line numberDiff line numberDiff line change
@@ -1069,3 +1069,61 @@ setup:
10691069
- match: { aggregations.test.buckets.1.doc_count: 2 }
10701070
- match: { aggregations.test.buckets.2.key.kw: null }
10711071
- match: { aggregations.test.buckets.2.doc_count: 2 }
1072+
1073+
---
1074+
"composite aggregation date_histogram profile shows filter rewrite info":
1075+
- skip:
1076+
version: " - 2.99.99"
1077+
reason: debug info for filter rewrite added in 3.0.0 (to be backported to 2.14.0)
1078+
1079+
- do:
1080+
indices.create:
1081+
index: test_2
1082+
body:
1083+
settings:
1084+
number_of_replicas: 0
1085+
number_of_shards: 1
1086+
mappings:
1087+
properties:
1088+
date:
1089+
type: date
1090+
- do:
1091+
bulk:
1092+
index: test_2
1093+
refresh: true
1094+
body:
1095+
- '{"index": {}}'
1096+
- '{"date": "2016-01-01"}'
1097+
- '{"index": {}}'
1098+
- '{"date": "2016-01-02"}'
1099+
- '{"index": {}}'
1100+
- '{"date": "2016-02-01"}'
1101+
- '{"index": {}}'
1102+
- '{"date": "2016-03-01"}'
1103+
- do:
1104+
search:
1105+
index: test_2
1106+
body:
1107+
size: 0
1108+
profile: true
1109+
aggregations:
1110+
test:
1111+
composite:
1112+
sources: [
1113+
{
1114+
"date": {
1115+
"date_histogram": {
1116+
"field": "date",
1117+
"calendar_interval": "1d",
1118+
"format": "strict_date"
1119+
}
1120+
}
1121+
}
1122+
]
1123+
1124+
- match: { hits.total.value: 4 }
1125+
- length: { aggregations.test.buckets: 4 }
1126+
- match: { profile.shards.0.aggregations.0.debug.optimized_segments: 1 }
1127+
- match: { profile.shards.0.aggregations.0.debug.unoptimized_segments: 0 }
1128+
- match: { profile.shards.0.aggregations.0.debug.leaf_visited: 1 }
1129+
- match: { profile.shards.0.aggregations.0.debug.inner_visited: 0 }

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/330_auto_date_histogram.yml

+26
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,29 @@ setup:
9999
- length: { aggregations.histo.buckets: 2 }
100100
- match: { profile.shards.0.aggregations.0.type: AutoDateHistogramAggregator.FromSingle }
101101
- match: { profile.shards.0.aggregations.0.debug.surviving_buckets: 4 }
102+
103+
---
104+
"auto_date_histogram profile shows filter rewrite info":
105+
- skip:
106+
version: " - 2.99.99"
107+
reason: debug info for filter rewrite added in 3.0.0 (to be backported to 2.14.0)
108+
109+
- do:
110+
search:
111+
body:
112+
profile: true
113+
size: 0
114+
aggs:
115+
histo:
116+
auto_date_histogram:
117+
field: date
118+
buckets: 2
119+
120+
- match: { hits.total.value: 4 }
121+
- length: { aggregations.histo.buckets: 2 }
122+
- match: { profile.shards.0.aggregations.0.type: AutoDateHistogramAggregator.FromSingle }
123+
- match: { profile.shards.0.aggregations.0.debug.surviving_buckets: 4 }
124+
- match: { profile.shards.0.aggregations.0.debug.optimized_segments: 1 }
125+
- match: { profile.shards.0.aggregations.0.debug.unoptimized_segments: 0 }
126+
- match: { profile.shards.0.aggregations.0.debug.leaf_visited: 1 }
127+
- match: { profile.shards.0.aggregations.0.debug.inner_visited: 0 }

server/src/main/java/org/opensearch/search/SearchService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
275275
// value 0 means rewrite filters optimization in aggregations will be disabled
276276
public static final Setting<Integer> MAX_AGGREGATION_REWRITE_FILTERS = Setting.intSetting(
277277
"search.max_aggregation_rewrite_filters",
278-
72,
278+
3000,
279279
0,
280280
Property.Dynamic,
281281
Property.NodeScope

0 commit comments

Comments
 (0)