mirror of
https://github.com/apache/lucene.git
synced 2025-02-28 13:29:26 +00:00
LUCENE-8656: Deprecations in FuzzyQuery (#1229)
LUCENE-8656: Deprecations in FuzzyQuery Closes #1229
This commit is contained in:
parent
d8bc9bcfcf
commit
d3ac1329a3
@ -82,6 +82,9 @@ Other
|
||||
|
||||
* LUCENE-9092: upgrade randomizedtesting to 2.7.5 (Dawid Weiss)
|
||||
|
||||
* LUCENE-8656: Deprecations in FuzzyQuery and get compiler warnings out of
|
||||
queryparser code (Alan Woodward, Erick Erickson)
|
||||
|
||||
======================= Lucene 8.5.0 =======================
|
||||
|
||||
API Changes
|
||||
|
@ -254,23 +254,15 @@ public class FuzzyQuery extends MultiTermQuery implements Accountable {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated pass integer edit distances instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public final static float defaultMinSimilarity = LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE;
|
||||
|
||||
/**
|
||||
* Helper function to convert from deprecated "minimumSimilarity" fractions
|
||||
* Helper function to convert from "minimumSimilarity" fractions
|
||||
* to raw edit distances.
|
||||
*
|
||||
* @param minimumSimilarity scaled similarity
|
||||
* @param termLen length (in unicode codepoints) of the term.
|
||||
* @return equivalent number of maxEdits
|
||||
* @deprecated pass integer edit distances instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static int floatToEdits(float minimumSimilarity, int termLen) {
|
||||
if (minimumSimilarity >= 1f) {
|
||||
return (int) Math.min(minimumSimilarity, LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);
|
||||
|
@ -106,10 +106,12 @@ public final class FastCharStream implements CharStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getColumn() {
|
||||
return bufferStart + bufferPosition;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getLine() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer
|
||||
|
||||
protected String field;
|
||||
int phraseSlop = 0;
|
||||
float fuzzyMinSim = FuzzyQuery.defaultMinSimilarity;
|
||||
float fuzzyMinSim = FuzzyQuery.defaultMaxEdits;
|
||||
int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
|
||||
Locale locale = Locale.getDefault();
|
||||
TimeZone timeZone = TimeZone.getDefault();
|
||||
|
@ -130,7 +130,7 @@ public interface CommonQueryParserConfiguration {
|
||||
|
||||
/**
|
||||
* Set the minimum similarity for fuzzy queries. Default is defined on
|
||||
* {@link FuzzyQuery#defaultMinSimilarity}.
|
||||
* {@link FuzzyQuery#defaultMaxEdits}.
|
||||
*/
|
||||
public void setFuzzyMinSim(float fuzzyMinSim);
|
||||
|
||||
|
@ -367,7 +367,7 @@ public class StandardQueryParser extends QueryParserHelper implements CommonQuer
|
||||
FuzzyConfig fuzzyConfig = getQueryConfigHandler().get(ConfigurationKeys.FUZZY_CONFIG);
|
||||
|
||||
if (fuzzyConfig == null) {
|
||||
return FuzzyQuery.defaultMinSimilarity;
|
||||
return FuzzyQuery.defaultMaxEdits;
|
||||
} else {
|
||||
return fuzzyConfig.getMinSimilarity();
|
||||
}
|
||||
@ -406,7 +406,7 @@ public class StandardQueryParser extends QueryParserHelper implements CommonQuer
|
||||
|
||||
/**
|
||||
* Set the minimum similarity for fuzzy queries. Default is defined on
|
||||
* {@link FuzzyQuery#defaultMinSimilarity}.
|
||||
* {@link FuzzyQuery#defaultMaxEdits}.
|
||||
*/
|
||||
@Override
|
||||
public void setFuzzyMinSim(float fuzzyMinSim) {
|
||||
|
@ -25,7 +25,7 @@ public class FuzzyConfig {
|
||||
|
||||
private int prefixLength = FuzzyQuery.defaultPrefixLength;
|
||||
|
||||
private float minSimilarity = FuzzyQuery.defaultMinSimilarity;
|
||||
private float minSimilarity = FuzzyQuery.defaultMaxEdits;
|
||||
|
||||
public FuzzyConfig() {}
|
||||
|
||||
|
@ -106,10 +106,12 @@ public final class FastCharStream implements CharStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getColumn() {
|
||||
return bufferStart + bufferPosition;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getLine() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC
|
||||
boolean endInc=false;
|
||||
QueryNode q =null;
|
||||
FieldQueryNode qLower, qUpper;
|
||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMaxEdits;
|
||||
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
|
||||
case TERM:
|
||||
case REGEXPTERM:
|
||||
|
@ -416,7 +416,7 @@ QueryNode Term(CharSequence field) : {
|
||||
boolean endInc=false;
|
||||
QueryNode q =null;
|
||||
FieldQueryNode qLower, qUpper;
|
||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMinSimilarity;
|
||||
float defaultMinSimilarity = org.apache.lucene.search.FuzzyQuery.defaultMaxEdits;
|
||||
}
|
||||
{
|
||||
(
|
||||
|
@ -105,10 +105,12 @@ public final class FastCharStream implements CharStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getColumn() {
|
||||
return bufferStart + bufferPosition;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public final int getLine() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.w3c.dom.NodeList;
|
||||
public class FuzzyLikeThisQueryBuilder implements QueryBuilder {
|
||||
|
||||
private static final int DEFAULT_MAX_NUM_TERMS = 50;
|
||||
private static final float DEFAULT_MIN_SIMILARITY = FuzzyQuery.defaultMinSimilarity;
|
||||
private static final float DEFAULT_MIN_SIMILARITY = FuzzyQuery.defaultMaxEdits;
|
||||
private static final int DEFAULT_PREFIX_LENGTH = 1;
|
||||
private static final boolean DEFAULT_IGNORE_TF = false;
|
||||
|
||||
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package org.apache.lucene.queryparser.flexible.core.builders;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode;
|
||||
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
|
||||
@ -34,13 +32,13 @@ public class TestQueryTreeBuilder extends LuceneTestCase {
|
||||
QueryTreeBuilder qtb = new QueryTreeBuilder();
|
||||
qtb.setBuilder("field", new DummyBuilder());
|
||||
Object result = qtb.build(new FieldQueryNode(new UnescapedCharSequence("field"), "foo", 0, 0));
|
||||
Assert.assertEquals("OK", result);
|
||||
assertEquals("OK", result);
|
||||
|
||||
// LUCENE-4890
|
||||
qtb = new QueryTreeBuilder();
|
||||
qtb.setBuilder(DummyQueryNodeInterface.class, new DummyBuilder());
|
||||
result = qtb.build(new DummyQueryNode());
|
||||
Assert.assertEquals("OK", result);
|
||||
assertEquals("OK", result);
|
||||
}
|
||||
|
||||
private static interface DummyQueryNodeInterface extends QueryNode {
|
||||
|
@ -131,7 +131,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder {
|
||||
|
||||
String defaultField;
|
||||
int phraseSlop = 0; // default slop for phrase queries
|
||||
float fuzzyMinSim = FuzzyQuery.defaultMinSimilarity;
|
||||
float fuzzyMinSim = FuzzyQuery.defaultMaxEdits;
|
||||
int fuzzyPrefixLength = FuzzyQuery.defaultPrefixLength;
|
||||
|
||||
boolean autoGeneratePhraseQueries = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user