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 Details

    • BASE_RAM_BYTES

      private static final long BASE_RAM_BYTES
    • terms

      private final BytesRefHash terms
    • ords

      private final int[] ords
    • fromField

      private final String fromField
    • fromQuery

      private final Query fromQuery
    • indexReaderContextId

      private final Object 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

      public void visit(QueryVisitor visitor)
      Description copied from class: Query
      Recurse through the query tree, visiting any child queries.
      Specified by:
      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 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:
      IOException
    • getTermsCount

      public long getTermsCount() throws IOException
      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 class MultiTermQuery
      Throws:
      IOException
    • toString

      public String toString(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(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 to those of the other instance. Utility methods are provided for certain repetitive code.

      Overrides:
      equals in class MultiTermQuery
      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 that QueryCache works properly.
      Overrides:
      hashCode in class MultiTermQuery
      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 interface Accountable