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 class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Analyzer
private final ArrayList<NearestFuzzyQuery.FieldVals>
private static final int
private static final int
private static final float
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds user input for "fuzzification"private void
boolean
Override and implement query instance equivalence properly in a subclass.private boolean
equalsTo
(NearestFuzzyQuery other) int
hashCode()
Override and implement query hash code properly in a subclass.private float
idf
(int docFreq, int docCount) private Query
newTermQuery
(IndexReader reader, Term term) rewrite
(IndexSearcher indexSearcher) Expert: called to re-write queries into primitive queries.Prints a query to a string, withfield
assumed to be the default field and omitted.void
visit
(QueryVisitor visitor) Recurse through the query tree, visiting any child queries.Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, 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:Query
Expert: 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
rewrite
multiple times if necessary, until the rewritten query is the same as the original query.The rewrite process may be able to make use of IndexSearcher's executor and be executed in parallel if the executor is provided.
However, if any of the intermediary queries do not satisfy the new API, parallel rewrite is not possible for any subsequent sub-queries. To take advantage of this API, the entire query tree must override this method.
- Overrides:
rewrite
in classQuery
- Throws:
IOException
- See Also:
-
toString
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted. -
hashCode
public int hashCode()Description copied from class:Query
Override and implement query hash code properly in a subclass. This is required so thatQueryCache
works properly. -
equals
Description copied from class:Query
Override and implement query instance equivalence properly in a subclass. This is required so thatQueryCache
works 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 to those of the other instance. Utility methods are provided for certain repetitive code.
-
equalsTo
-
visit
Description copied from class:Query
Recurse through the query tree, visiting any child queries.
-