Skip to content

Commit 691ff25

Browse files
committed
add change log and test
Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
1 parent 386a24b commit 691ff25

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2020
- Add support for more than one protocol for transport ([#12967](https://github.com/opensearch-project/OpenSearch/pull/12967))
2121
- [Tiered Caching] Add dimension-based stats to ICache implementations. ([#12531](https://github.com/opensearch-project/OpenSearch/pull/12531))
2222
- Add changes for overriding remote store and replication settings during snapshot restore. ([#11868](https://github.com/opensearch-project/OpenSearch/pull/11868))
23+
- Add cluster setting to dynamically disable filter rewrite optimization. ([#13179](https://github.com/opensearch-project/OpenSearch/pull/13179))
2324

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

server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterRewriteIT.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1212

13+
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
1314
import org.opensearch.action.index.IndexRequestBuilder;
1415
import org.opensearch.action.search.SearchResponse;
1516
import org.opensearch.common.settings.Settings;
@@ -93,7 +94,7 @@ public void testMinDocCountOnDateHistogram() throws Exception {
9394
final SearchResponse allResponse = client().prepareSearch("idx")
9495
.setSize(0)
9596
.setQuery(QUERY)
96-
.addAggregation(dateHistogram("histo").field("date").dateHistogramInterval(DateHistogramInterval.DAY).minDocCount(0))
97+
.addAggregation(dateHistogram("histo").field("date").calendarInterval(DateHistogramInterval.DAY).minDocCount(0))
9798
.get();
9899

99100
final Histogram allHisto = allResponse.getAggregations().get("histo");
@@ -104,4 +105,38 @@ public void testMinDocCountOnDateHistogram() throws Exception {
104105
assertEquals(entry.getValue(), results.get(entry.getKey()));
105106
}
106107
}
108+
109+
public void testDisableOptimizationGivesSameResults() throws Exception {
110+
SearchResponse response = client().prepareSearch("idx")
111+
.setSize(0)
112+
.setQuery(QUERY)
113+
.addAggregation(dateHistogram("histo").field("date").calendarInterval(DateHistogramInterval.DAY).minDocCount(0))
114+
.get();
115+
116+
final Histogram allHisto1 = response.getAggregations().get("histo");
117+
118+
final ClusterUpdateSettingsResponse updateSettingResponse = client().admin()
119+
.cluster()
120+
.prepareUpdateSettings()
121+
.setTransientSettings(Settings.builder().put("search.filter_rewrite.enabled", false))
122+
.get();
123+
124+
assertEquals(updateSettingResponse.getTransientSettings().get("search.filter_rewrite.enabled"), "false");
125+
126+
response = client().prepareSearch("idx")
127+
.setSize(0)
128+
.setQuery(QUERY)
129+
.addAggregation(dateHistogram("histo").field("date").calendarInterval(DateHistogramInterval.DAY).minDocCount(0))
130+
.get();
131+
132+
final Histogram allHisto2 = response.getAggregations().get("histo");
133+
134+
assertEquals(allHisto1, allHisto2);
135+
136+
client().admin()
137+
.cluster()
138+
.prepareUpdateSettings()
139+
.setTransientSettings(Settings.builder().putNull("search.filter_rewrite.enabled"))
140+
.get();
141+
}
107142
}

0 commit comments

Comments
 (0)