|
15 | 15 | import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
|
16 | 16 | import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
|
17 | 17 |
|
| 18 | +import java.io.IOException; |
18 | 19 | import java.util.List;
|
19 | 20 | import java.util.Locale;
|
20 | 21 |
|
@@ -109,6 +110,53 @@ public void testPercolatorUnmappedFieldsAsStringCheck() {
|
109 | 110 | assertTrue(noIssues.isEmpty());
|
110 | 111 | }
|
111 | 112 |
|
| 113 | + public void testClassicSimilarityMappingCheck() throws IOException { |
| 114 | + String mappingJson = "{\n" + |
| 115 | + " \"properties\": {\n" + |
| 116 | + " \"default_field\": {\n" + |
| 117 | + " \"type\": \"text\"\n" + |
| 118 | + " },\n" + |
| 119 | + " \"classic_sim_field\": {\n" + |
| 120 | + " \"type\": \"text\",\n" + |
| 121 | + " \"similarity\": \"classic\"\n" + |
| 122 | + " }\n" + |
| 123 | + " }\n" + |
| 124 | + "}"; |
| 125 | + IndexMetaData index = IndexMetaData.builder(randomAlphaOfLengthBetween(5,10)) |
| 126 | + .settings(settings( |
| 127 | + VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.CURRENT)))) |
| 128 | + .numberOfShards(randomIntBetween(1,100)) |
| 129 | + .numberOfReplicas(randomIntBetween(1, 100)) |
| 130 | + .putMapping("_doc", mappingJson) |
| 131 | + .build(); |
| 132 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 133 | + "Classic similarity has been removed", |
| 134 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/" + |
| 135 | + "#_the_literal_classic_literal_similarity_has_been_removed", |
| 136 | + "Fields which use classic similarity: [[type: _doc, field: classic_sim_field]]"); |
| 137 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(index)); |
| 138 | + assertEquals(singletonList(expected), issues); |
| 139 | + } |
| 140 | + |
| 141 | + public void testClassicSimilaritySettingsCheck() { |
| 142 | + IndexMetaData index = IndexMetaData.builder(randomAlphaOfLengthBetween(5, 10)) |
| 143 | + .settings(settings( |
| 144 | + VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.CURRENT))) |
| 145 | + .put("index.similarity.my_classic_similarity.type", "classic") |
| 146 | + .put("index.similarity.my_okay_similarity.type", "BM25")) |
| 147 | + .numberOfShards(randomIntBetween(1, 100)) |
| 148 | + .numberOfReplicas(randomIntBetween(1, 100)) |
| 149 | + .build(); |
| 150 | + |
| 151 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 152 | + "Classic similarity has been removed", |
| 153 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/" + |
| 154 | + "#_the_literal_classic_literal_similarity_has_been_removed", |
| 155 | + "Custom similarities defined using classic similarity: [my_classic_similarity]"); |
| 156 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(index)); |
| 157 | + assertEquals(singletonList(expected), issues); |
| 158 | + } |
| 159 | + |
112 | 160 | public void testNodeLeftDelayedTimeCheck() {
|
113 | 161 | String negativeTimeValue = "-" + randomPositiveTimeValue();
|
114 | 162 | String indexName = randomAlphaOfLengthBetween(0, 10);
|
|
0 commit comments