Class 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.
    • Field Detail

      • BASE_RAM_BYTES

        private static final long BASE_RAM_BYTES
      • 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
        Overrides:
        visit in class Query
        Parameters:
        visitor - a QueryVisitor to be called by each query in the tree
      • 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 return TermsEnum.EMPTY if no terms match). The TermsEnum must already be positioned to the first matching term. The given AttributeSource is passed by the MultiTermQuery.RewriteMethod to share information between segments, for example TopTermsRewrite uses it to share maximum competitive boosts
        Specified by:
        getTermsEnum in class MultiTermQuery
        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, with field assumed to be the default field and omitted.
        Specified by:
        toString in class Query
      • 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 that QueryCache 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 class MultiTermQuery
        See Also:
        Query.sameClassAs(Object), Query.classHash()
      • 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 interface Accountable