-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Deprecating levenstein in favor of levensHtein
#27409
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| package org.elasticsearch.search.suggest.phrase; | ||
|
|
||
| import org.apache.lucene.search.spell.LevensteinDistance; | ||
| import org.elasticsearch.common.ParsingException; | ||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.xcontent.ToXContent; | ||
|
|
@@ -38,6 +39,7 @@ | |
| import java.util.function.Supplier; | ||
|
|
||
| import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| public class DirectCandidateGeneratorTests extends ESTestCase { | ||
| private static final int NUMBER_OF_RUNS = 20; | ||
|
|
@@ -65,6 +67,11 @@ public void testEqualsAndHashcode() throws IOException { | |
| } | ||
| } | ||
|
|
||
| public void testLevensteinDeprecation() { | ||
| assertThat(DirectCandidateGeneratorBuilder.resolveDistance("levenstein"), equalTo(new LevensteinDistance())); | ||
|
||
| assertWarnings("Deprecated distance [levenstein] used, replaced by [levenshtein]"); | ||
| } | ||
|
|
||
| private static DirectCandidateGeneratorBuilder mutate(DirectCandidateGeneratorBuilder original) throws IOException { | ||
| DirectCandidateGeneratorBuilder mutation = copy(original); | ||
| List<Supplier<DirectCandidateGeneratorBuilder>> mutators = new ArrayList<>(); | ||
|
|
@@ -89,7 +96,7 @@ private static DirectCandidateGeneratorBuilder mutate(DirectCandidateGeneratorBu | |
| mutators.add(() -> mutation.preFilter(original.preFilter() == null ? "preFilter" : original.preFilter() + "_other")); | ||
| mutators.add(() -> mutation.sort(original.sort() == null ? "score" : original.sort() + "_other")); | ||
| mutators.add( | ||
| () -> mutation.stringDistance(original.stringDistance() == null ? "levenstein" : original.stringDistance() + "_other")); | ||
| () -> mutation.stringDistance(original.stringDistance() == null ? "levenshtein" : original.stringDistance() + "_other")); | ||
| mutators.add(() -> mutation.suggestMode(original.suggestMode() == null ? "missing" : original.suggestMode() + "_other")); | ||
| return randomFrom(mutators).get(); | ||
| } | ||
|
|
@@ -189,7 +196,7 @@ public static DirectCandidateGeneratorBuilder randomCandidateGenerator() { | |
| maybeSet(generator::postFilter, randomAlphaOfLengthBetween(1, 20)); | ||
| maybeSet(generator::size, randomIntBetween(1, 20)); | ||
| maybeSet(generator::sort, randomFrom("score", "frequency")); | ||
| maybeSet(generator::stringDistance, randomFrom("internal", "damerau_levenshtein", "levenstein", "jarowinkler", "ngram")); | ||
| maybeSet(generator::stringDistance, randomFrom("internal", "damerau_levenshtein", "levenshtein", "jarowinkler", "ngram")); | ||
| maybeSet(generator::suggestMode, randomFrom("missing", "popular", "always")); | ||
| return generator; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a shame to leave this TODO here. Would you care to fix that too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No scope creep please. 😄