Class NearestFuzzyQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.classification.utils.NearestFuzzyQuery
Simplification of FuzzyLikeThisQuery, to be used in the context of KNN classification.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Analyzerprivate final ArrayList<NearestFuzzyQuery.FieldVals>private static final intprivate static final intprivate static final floatprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds user input for "fuzzification"private voidbooleanOverride and implement query instance equivalence properly in a subclass.private booleanequalsTo(NearestFuzzyQuery other) inthashCode()Override and implement query hash code properly in a subclass.private floatidf(int docFreq, int docCount) private QuerynewTermQuery(IndexReader reader, Term term) rewrite(IndexReader reader) Expert: called to re-write queries into primitive queries.Prints a query to a string, withfieldassumed to be the default field and omitted.voidvisit(QueryVisitor visitor) Recurse through the query tree, visiting any child queriesMethods inherited from class org.apache.lucene.search.Query
classHash, createWeight, sameClassAs, toString
-
Field Details
-
fieldVals
-
analyzer
-
MAX_VARIANTS_PER_TERM
private static final int MAX_VARIANTS_PER_TERM- See Also:
-
MIN_SIMILARITY
private static final float MIN_SIMILARITY- See Also:
-
PREFIX_LENGTH
private static final int PREFIX_LENGTH- See Also:
-
MAX_NUM_TERMS
private static final int MAX_NUM_TERMS- See Also:
-
-
Constructor Details
-
NearestFuzzyQuery
Default constructor- Parameters:
analyzer- the analyzer used to process the query text
-
-
Method Details
-
addTerms
Adds user input for "fuzzification"- Parameters:
queryString- The string which will be parsed by the analyzer and for which fuzzy variants will be parsed
-
addTerms
private void addTerms(IndexReader reader, NearestFuzzyQuery.FieldVals f, NearestFuzzyQuery.ScoreTermQueue q) throws IOException - Throws:
IOException
-
idf
private float idf(int docFreq, int docCount) -
newTermQuery
- Throws:
IOException
-
rewrite
Description copied from class:QueryExpert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.Callers are expected to call
rewritemultiple times if necessary, until the rewritten query is the same as the original query.- Overrides:
rewritein classQuery- Throws:
IOException- See Also:
-
toString
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted. -
hashCode
public int hashCode()Description copied from class:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly. -
equals
Description copied from class:QueryOverride and implement query instance equivalence properly in a subclass. This is required so thatQueryCacheworks properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical that other instance. Utility methods are provided for certain repetitive code.
-
equalsTo
-
visit
Description copied from class:QueryRecurse through the query tree, visiting any child queries
-