java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.MultiTermQuery
org.apache.lucene.search.join.TermsQuery
- All Implemented Interfaces:
Accountable
A query that has an array of terms from a specific field. This query will match documents have
one or more terms in the specified field that match with the terms specified in the array.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.MultiTermQuery
MultiTermQuery.RewriteMethod, MultiTermQuery.TopTermsBlendedFreqScoringRewrite, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private final String
private final Query
private final Object
private final int[]
private final long
private final BytesRefHash
Fields inherited from class org.apache.lucene.search.MultiTermQuery
CONSTANT_SCORE_BLENDED_REWRITE, CONSTANT_SCORE_BOOLEAN_REWRITE, CONSTANT_SCORE_REWRITE, DOC_VALUES_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_REWRITE
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
ConstructorsConstructorDescriptionTermsQuery
(String toField, BytesRefHash terms, String fromField, Query fromQuery, Object indexReaderContextId) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Override and implement query instance equivalence properly in a subclass.long
Return the number of unique terms contained in this query, if known up-front.protected TermsEnum
getTermsEnum
(Terms terms, AttributeSource atts) Construct the enumeration to be used, expanding the pattern term.int
hashCode()
Override and implement query hash code properly in a subclass.long
Return the memory usage of this object in bytes.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.MultiTermQuery
getField, getRewriteMethod, getTermsEnum, rewrite, setRewriteMethod
Methods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, sameClassAs, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
BASE_RAM_BYTES
private static final long BASE_RAM_BYTES -
terms
-
ords
private final int[] ords -
fromField
-
fromQuery
-
indexReaderContextId
-
ramBytesUsed
private final long ramBytesUsed
-
-
Constructor Details
-
TermsQuery
TermsQuery(String toField, BytesRefHash terms, String fromField, Query fromQuery, Object indexReaderContextId) - Parameters:
toField
- The field that should contain terms that are specified in the next parameter.terms
- The terms that matching documents should have. The terms must be sorted by natural order.indexReaderContextId
- Refers to the top level index reader used to create the set of terms in the previous parameter.
-
-
Method Details
-
visit
Description copied from class:Query
Recurse through the query tree, visiting any child queries. -
getTermsEnum
Description copied from class:MultiTermQuery
Construct the enumeration to be used, expanding the pattern term. This method should only be called if the field exists (ie, implementations can assume the field does exist). This method should not return null (should instead returnTermsEnum.EMPTY
if no terms match). The TermsEnum must already be positioned to the first matching term. The givenAttributeSource
is passed by theMultiTermQuery.RewriteMethod
to share information between segments, for exampleTopTermsRewrite
uses it to share maximum competitive boosts- Specified by:
getTermsEnum
in classMultiTermQuery
- Throws:
IOException
-
getTermsCount
Description copied from class:MultiTermQuery
Return the number of unique terms contained in this query, if known up-front. If not known, -1 will be returned.- Overrides:
getTermsCount
in classMultiTermQuery
- Throws:
IOException
-
toString
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted. -
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.
- Overrides:
equals
in classMultiTermQuery
- See Also:
-
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.- Overrides:
hashCode
in classMultiTermQuery
- See Also:
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsed
in interfaceAccountable
-