Skip to content

Commit

Permalink
Restore AnalysisModuleTests#testStandardFilterBWC (#119060)
Browse files Browse the repository at this point in the history
This test has been removed with #112570 but with
the coming read-only support for v7 we need it back.
  • Loading branch information
cbuescher authored Dec 19, 2024
1 parent 20a3492 commit 0a9b5b7
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.elasticsearch.index.IndexService.IndexCreationContext;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.analysis.Analysis;
import org.elasticsearch.index.analysis.AnalysisRegistry;
import org.elasticsearch.index.analysis.CharFilterFactory;
Expand Down Expand Up @@ -186,6 +187,34 @@ public void testUnderscoreInAnalyzerName() throws IOException {
}
}

public void testStandardFilterBWC() throws IOException {
// standard tokenfilter should have been removed entirely in the 7x line. However, a
// cacheing bug meant that it was still possible to create indexes using a standard
// filter until 7.6
{
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_6_0, IndexVersion.current());
final Settings settings = Settings.builder()
.put("index.analysis.analyzer.my_standard.tokenizer", "standard")
.put("index.analysis.analyzer.my_standard.filter", "standard")
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.put(IndexMetadata.SETTING_VERSION_CREATED, version)
.build();
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> getIndexAnalyzers(settings));
assertThat(exc.getMessage(), equalTo("The [standard] token filter has been removed."));
}
{
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.V_7_0_0, IndexVersions.V_7_5_2);
final Settings settings = Settings.builder()
.put("index.analysis.analyzer.my_standard.tokenizer", "standard")
.put("index.analysis.analyzer.my_standard.filter", "standard")
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.put(IndexMetadata.SETTING_VERSION_CREATED, version)
.build();
getIndexAnalyzers(settings);
assertWarnings("The [standard] token filter is deprecated and will be removed in a future version.");
}
}

/**
* Tests that plugins can register pre-configured char filters that vary in behavior based on Elasticsearch version, Lucene version,
* and that do not vary based on version at all.
Expand Down

0 comments on commit 0a9b5b7

Please sign in to comment.