Skip to content

Commit 0a9b5b7

Browse files
authored
Restore AnalysisModuleTests#testStandardFilterBWC (#119060)
This test has been removed with #112570 but with the coming read-only support for v7 we need it back.
1 parent 20a3492 commit 0a9b5b7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.elasticsearch.index.IndexService.IndexCreationContext;
2323
import org.elasticsearch.index.IndexSettings;
2424
import org.elasticsearch.index.IndexVersion;
25+
import org.elasticsearch.index.IndexVersions;
2526
import org.elasticsearch.index.analysis.Analysis;
2627
import org.elasticsearch.index.analysis.AnalysisRegistry;
2728
import org.elasticsearch.index.analysis.CharFilterFactory;
@@ -186,6 +187,34 @@ public void testUnderscoreInAnalyzerName() throws IOException {
186187
}
187188
}
188189

190+
public void testStandardFilterBWC() throws IOException {
191+
// standard tokenfilter should have been removed entirely in the 7x line. However, a
192+
// cacheing bug meant that it was still possible to create indexes using a standard
193+
// filter until 7.6
194+
{
195+
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_6_0, IndexVersion.current());
196+
final Settings settings = Settings.builder()
197+
.put("index.analysis.analyzer.my_standard.tokenizer", "standard")
198+
.put("index.analysis.analyzer.my_standard.filter", "standard")
199+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
200+
.put(IndexMetadata.SETTING_VERSION_CREATED, version)
201+
.build();
202+
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> getIndexAnalyzers(settings));
203+
assertThat(exc.getMessage(), equalTo("The [standard] token filter has been removed."));
204+
}
205+
{
206+
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_0_0, IndexVersions.V_7_5_2);
207+
final Settings settings = Settings.builder()
208+
.put("index.analysis.analyzer.my_standard.tokenizer", "standard")
209+
.put("index.analysis.analyzer.my_standard.filter", "standard")
210+
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
211+
.put(IndexMetadata.SETTING_VERSION_CREATED, version)
212+
.build();
213+
getIndexAnalyzers(settings);
214+
assertWarnings("The [standard] token filter is deprecated and will be removed in a future version.");
215+
}
216+
}
217+
189218
/**
190219
* Tests that plugins can register pre-configured char filters that vary in behavior based on Elasticsearch version, Lucene version,
191220
* and that do not vary based on version at all.

0 commit comments

Comments
 (0)