Remove deprecated names for string distance algorithms (#27640)

#27409 deprecated the incorrectly-spelled `levenstein` in favour of `levenshtein`.
#27526 deprecated the inconsistent `jarowinkler` in favour of `jaro_winkler`.

These changes were merged into 6.2, and this change removes them entirely in 7.0.
This commit is contained in:
olcbean 2017-12-11 13:16:04 +01:00 committed by David Turner
parent 85dd1880fc
commit 25c606cf09
5 changed files with 14 additions and 39 deletions

View File

@ -464,19 +464,13 @@ public final class DirectCandidateGeneratorBuilder implements CandidateGenerator
} }
static StringDistance resolveDistance(String distanceVal) { static StringDistance resolveDistance(String distanceVal) {
distanceVal = distanceVal.toLowerCase(Locale.US); distanceVal = distanceVal.toLowerCase(Locale.ROOT);
if ("internal".equals(distanceVal)) { if ("internal".equals(distanceVal)) {
return DirectSpellChecker.INTERNAL_LEVENSHTEIN; return DirectSpellChecker.INTERNAL_LEVENSHTEIN;
} else if ("damerau_levenshtein".equals(distanceVal) || "damerauLevenshtein".equals(distanceVal)) { } else if ("damerau_levenshtein".equals(distanceVal)) {
return new LuceneLevenshteinDistance(); return new LuceneLevenshteinDistance();
} else if ("levenstein".equals(distanceVal)) {
DEPRECATION_LOGGER.deprecated("Deprecated distance [levenstein] used, replaced by [levenshtein]");
return new LevensteinDistance();
} else if ("levenshtein".equals(distanceVal)) { } else if ("levenshtein".equals(distanceVal)) {
return new LevensteinDistance(); return new LevensteinDistance();
} else if ("jarowinkler".equals(distanceVal)) {
DEPRECATION_LOGGER.deprecated("Deprecated distance [jarowinkler] used, replaced by [jaro_winkler]");
return new JaroWinklerDistance();
} else if ("jaro_winkler".equals(distanceVal)) { } else if ("jaro_winkler".equals(distanceVal)) {
return new JaroWinklerDistance(); return new JaroWinklerDistance();
} else if ("ngram".equals(distanceVal)) { } else if ("ngram".equals(distanceVal)) {

View File

@ -581,23 +581,16 @@ public class TermSuggestionBuilder extends SuggestionBuilder<TermSuggestionBuild
public static StringDistanceImpl resolve(final String str) { public static StringDistanceImpl resolve(final String str) {
Objects.requireNonNull(str, "Input string is null"); Objects.requireNonNull(str, "Input string is null");
final String distanceVal = str.toLowerCase(Locale.US); final String distanceVal = str.toLowerCase(Locale.ROOT);
switch (distanceVal) { switch (distanceVal) {
case "internal": case "internal":
return INTERNAL; return INTERNAL;
case "damerau_levenshtein": case "damerau_levenshtein":
case "damerauLevenshtein":
return DAMERAU_LEVENSHTEIN; return DAMERAU_LEVENSHTEIN;
case "levenstein":
DEPRECATION_LOGGER.deprecated("Deprecated distance [levenstein] used, replaced by [levenshtein]");
return LEVENSHTEIN;
case "levenshtein": case "levenshtein":
return LEVENSHTEIN; return LEVENSHTEIN;
case "ngram": case "ngram":
return NGRAM; return NGRAM;
case "jarowinkler":
DEPRECATION_LOGGER.deprecated("Deprecated distance [jarowinkler] used, replaced by [jaro_winkler]");
return JARO_WINKLER;
case "jaro_winkler": case "jaro_winkler":
return JARO_WINKLER; return JARO_WINKLER;
default: throw new IllegalArgumentException("Illegal distance option " + str); default: throw new IllegalArgumentException("Illegal distance option " + str);

View File

@ -83,16 +83,6 @@ public class DirectCandidateGeneratorTests extends ESTestCase {
expectThrows(NullPointerException.class, () -> DirectCandidateGeneratorBuilder.resolveDistance(null)); expectThrows(NullPointerException.class, () -> DirectCandidateGeneratorBuilder.resolveDistance(null));
} }
public void testLevensteinDeprecation() {
assertThat(DirectCandidateGeneratorBuilder.resolveDistance("levenstein"), instanceOf(LevensteinDistance.class));
assertWarnings("Deprecated distance [levenstein] used, replaced by [levenshtein]");
}
public void testJaroWinklerDeprecation() {
assertThat(DirectCandidateGeneratorBuilder.resolveDistance("jaroWinkler"), instanceOf(JaroWinklerDistance.class));
assertWarnings("Deprecated distance [jarowinkler] used, replaced by [jaro_winkler]");
}
private static DirectCandidateGeneratorBuilder mutate(DirectCandidateGeneratorBuilder original) throws IOException { private static DirectCandidateGeneratorBuilder mutate(DirectCandidateGeneratorBuilder original) throws IOException {
DirectCandidateGeneratorBuilder mutation = copy(original); DirectCandidateGeneratorBuilder mutation = copy(original);
List<Supplier<DirectCandidateGeneratorBuilder>> mutators = new ArrayList<>(); List<Supplier<DirectCandidateGeneratorBuilder>> mutators = new ArrayList<>();

View File

@ -58,16 +58,6 @@ public class StringDistanceImplTests extends AbstractWriteableEnumTestCase {
assertThat(e.getMessage(), equalTo("Input string is null")); assertThat(e.getMessage(), equalTo("Input string is null"));
} }
public void testLevensteinDeprecation() {
assertThat(StringDistanceImpl.resolve("levenstein"), equalTo(StringDistanceImpl.LEVENSHTEIN));
assertWarnings("Deprecated distance [levenstein] used, replaced by [levenshtein]");
}
public void testJaroWinklerDeprecation() {
assertThat(StringDistanceImpl.resolve("jaroWinkler"), equalTo(StringDistanceImpl.JARO_WINKLER));
assertWarnings("Deprecated distance [jarowinkler] used, replaced by [jaro_winkler]");
}
@Override @Override
public void testWriteTo() throws IOException { public void testWriteTo() throws IOException {
assertWriteToStream(StringDistanceImpl.INTERNAL, 0); assertWriteToStream(StringDistanceImpl.INTERNAL, 0);
@ -85,5 +75,4 @@ public class StringDistanceImplTests extends AbstractWriteableEnumTestCase {
assertReadFromStream(3, StringDistanceImpl.JARO_WINKLER); assertReadFromStream(3, StringDistanceImpl.JARO_WINKLER);
assertReadFromStream(4, StringDistanceImpl.NGRAM); assertReadFromStream(4, StringDistanceImpl.NGRAM);
} }
} }

View File

@ -35,8 +35,17 @@ The Search API returns `400 - Bad request` while it would previously return
* number of filters in the adjacency matrix aggregation is too large * number of filters in the adjacency matrix aggregation is too large
==== Scroll queries cannot use the request_cache anymore ==== Scroll queries cannot use the `request_cache` anymore
Setting `request_cache:true` on a query that creates a scroll ('scroll=1m`) Setting `request_cache:true` on a query that creates a scroll (`scroll=1m`)
has been deprecated in 6 and will now return a `400 - Bad request`. has been deprecated in 6 and will now return a `400 - Bad request`.
Scroll queries are not meant to be cached. Scroll queries are not meant to be cached.
==== Term Suggesters supported distance algorithms
The following string distance algorithms were given additional names in 6.2 and
their existing names were deprecated. The deprecated names have now been
removed.
* `levenstein` - replaced by `levenshtein`
* `jarowinkler` - replaced by `jaro_winkler`