|
22 | 22 | import org.elasticsearch.index.IndexService.IndexCreationContext; |
23 | 23 | import org.elasticsearch.index.IndexSettings; |
24 | 24 | import org.elasticsearch.index.IndexVersion; |
| 25 | +import org.elasticsearch.index.IndexVersions; |
25 | 26 | import org.elasticsearch.index.analysis.Analysis; |
26 | 27 | import org.elasticsearch.index.analysis.AnalysisRegistry; |
27 | 28 | import org.elasticsearch.index.analysis.CharFilterFactory; |
@@ -186,6 +187,34 @@ public void testUnderscoreInAnalyzerName() throws IOException { |
186 | 187 | } |
187 | 188 | } |
188 | 189 |
|
| 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 | + |
189 | 218 | /** |
190 | 219 | * Tests that plugins can register pre-configured char filters that vary in behavior based on Elasticsearch version, Lucene version, |
191 | 220 | * and that do not vary based on version at all. |
|
0 commit comments