LUCENE-4024: fix off-by-one in backwards layer

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1338668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-05-15 12:32:06 +00:00
parent e42ebbcb93
commit eef4f63f08
2 changed files with 2 additions and 1 deletions

View File

@ -206,7 +206,7 @@ public class FuzzyQuery extends MultiTermQuery {
*/ */
@Deprecated @Deprecated
public static int floatToEdits(float minimumSimilarity, int termLen) { public static int floatToEdits(float minimumSimilarity, int termLen) {
if (minimumSimilarity > 1f) { if (minimumSimilarity >= 1f) {
return (int) Math.min(minimumSimilarity, LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE); return (int) Math.min(minimumSimilarity, LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);
} else if (minimumSimilarity == 0.0f) { } else if (minimumSimilarity == 0.0f) {
return 0; // 0 means exact, not infinite # of edits! return 0; // 0 means exact, not infinite # of edits!

View File

@ -421,6 +421,7 @@ public abstract class QueryParserTestBase extends LuceneTestCase {
assertQueryEquals("term*", null, "term*"); assertQueryEquals("term*", null, "term*");
assertQueryEquals("term*^2", null, "term*^2.0"); assertQueryEquals("term*^2", null, "term*^2.0");
assertQueryEquals("term~", null, "term~2"); assertQueryEquals("term~", null, "term~2");
assertQueryEquals("term~1", null, "term~1");
assertQueryEquals("term~0.7", null, "term~1"); assertQueryEquals("term~0.7", null, "term~1");
assertQueryEquals("term~^3", null, "term~2^3.0"); assertQueryEquals("term~^3", null, "term~2^3.0");
assertQueryEquals("term^3~", null, "term~2^3.0"); assertQueryEquals("term^3~", null, "term~2^3.0");