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 longprivate final Stringprivate final Queryprivate final Objectprivate final int[]private final longprivate final BytesRefHashFields 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_REWRITEFields 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 TypeMethodDescriptionbooleanOverride and implement query instance equivalence properly in a subclass.longReturn the number of unique terms contained in this query, if known up-front.protected TermsEnumgetTermsEnum(Terms terms, AttributeSource atts) Construct the enumeration to be used, expanding the pattern term.inthashCode()Override and implement query hash code properly in a subclass.longReturn the memory usage of this object in bytes.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 queries.Methods inherited from class org.apache.lucene.search.MultiTermQuery
getField, getRewriteMethod, getTermsEnum, rewrite, setRewriteMethodMethods inherited from class org.apache.lucene.search.Query
classHash, createWeight, rewrite, sameClassAs, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:QueryRecurse through the query tree, visiting any child queries. -
getTermsEnum
Description copied from class:MultiTermQueryConstruct 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.EMPTYif no terms match). The TermsEnum must already be positioned to the first matching term. The givenAttributeSourceis passed by theMultiTermQuery.RewriteMethodto share information between segments, for exampleTopTermsRewriteuses it to share maximum competitive boosts- Specified by:
getTermsEnumin classMultiTermQuery- Throws:
IOException
-
getTermsCount
Description copied from class:MultiTermQueryReturn the number of unique terms contained in this query, if known up-front. If not known, -1 will be returned.- Overrides:
getTermsCountin classMultiTermQuery- Throws:
IOException
-
toString
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted. -
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 to those of the other instance. Utility methods are provided for certain repetitive code.
- Overrides:
equalsin classMultiTermQuery- See Also:
-
hashCode
public int hashCode()Description copied from class:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly.- Overrides:
hashCodein classMultiTermQuery- See Also:
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.- Specified by:
ramBytesUsedin interfaceAccountable
-