Package org.apache.lucene.search.join
Class TermsQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.MultiTermQuery
-
- org.apache.lucene.search.join.TermsQuery
-
- All Implemented Interfaces:
Accountable
class TermsQuery extends MultiTermQuery implements 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
Fields Modifier and Type Field Description private static long
BASE_RAM_BYTES
private java.lang.String
fromField
private Query
fromQuery
private java.lang.Object
indexReaderContextId
private int[]
ords
private long
ramBytesUsed
private BytesRefHash
terms
-
Fields inherited from class org.apache.lucene.search.MultiTermQuery
CONSTANT_SCORE_BOOLEAN_REWRITE, CONSTANT_SCORE_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_REWRITE
-
-
Constructor Summary
Constructors Constructor Description TermsQuery(java.lang.String toField, BytesRefHash terms, java.lang.String fromField, Query fromQuery, java.lang.Object indexReaderContextId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Override and implement query instance equivalence properly in a subclass.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
ramBytesUsed()
Return the memory usage of this object in bytes.java.lang.String
toString(java.lang.String string)
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, 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 Detail
-
BASE_RAM_BYTES
private static final long BASE_RAM_BYTES
-
terms
private final BytesRefHash terms
-
ords
private final int[] ords
-
fromField
private final java.lang.String fromField
-
fromQuery
private final Query fromQuery
-
indexReaderContextId
private final java.lang.Object indexReaderContextId
-
ramBytesUsed
private final long ramBytesUsed
-
-
Constructor Detail
-
TermsQuery
TermsQuery(java.lang.String toField, BytesRefHash terms, java.lang.String fromField, Query fromQuery, java.lang.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 Detail
-
visit
public void visit(QueryVisitor visitor)
Description copied from class:Query
Recurse through the query tree, visiting any child queries
-
getTermsEnum
protected TermsEnum getTermsEnum(Terms terms, AttributeSource atts) throws java.io.IOException
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 provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts. This is currently only used byTopTermsRewrite
- Specified by:
getTermsEnum
in classMultiTermQuery
- Throws:
java.io.IOException
-
toString
public java.lang.String toString(java.lang.String string)
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted.
-
equals
public boolean equals(java.lang.Object obj)
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 that other instance. Utility methods are provided for certain repetitive code.- Overrides:
equals
in classMultiTermQuery
- See Also:
Query.sameClassAs(Object)
,Query.classHash()
-
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:
Query.equals(Object)
-
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
-
-