Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix standard filter BWC check to allow for cacheing bug #62649

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static Map<String, PreConfiguredTokenFilter> setupPreConfiguredTokenFilters(List
// Add "standard" for old indices (bwc)
preConfiguredTokenFilters.register( "standard",
PreConfiguredTokenFilter.elasticsearchVersion("standard", true, (reader, version) -> {
if (version.before(Version.V_7_0_0)) {
if (version.before(Version.V_7_6_0)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here so that we don't forget why it's 7.6 and not 7.0 ?

deprecationLogger.deprecate("standard_deprecation",
"The [standard] token filter is deprecated and will be removed in a future version.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,28 @@ public void testUnderscoreInAnalyzerName() throws IOException {
}
}

public void testStandardFilterBWC() {
Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT);
final Settings settings = Settings.builder().put("index.analysis.analyzer.my_standard.tokenizer", "standard")
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
{
Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_6_0, Version.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."));
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> getIndexAnalyzers(settings));
assertThat(exc.getMessage(), equalTo("The [standard] token filter has been removed."));
}
{
Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.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.");
}
}

/**
Expand Down