Class MultiTermQuery

    • Constructor Detail

      • MultiTermQuery

        public MultiTermQuery​(String field,
                              MultiTermQuery.RewriteMethod rewriteMethod)
        Constructs a query matching terms that cannot be represented with a single Term.
    • Method Detail

      • getField

        public final String getField()
        Returns the field name for this query
      • getTermsEnum

        protected abstract TermsEnum getTermsEnum​(Terms terms,
                                                  AttributeSource atts)
                                           throws IOException
        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
        Throws:
        IOException
      • getTermsEnum

        public final TermsEnum getTermsEnum​(Terms terms)
                                     throws IOException
        Constructs an enumeration that expands the pattern term. This method should only be called if the field exists (ie, implementations can assume the field does exist). This method never returns null. The returned TermsEnum is positioned to the first matching term.
        Throws:
        IOException
      • getTermsCount

        public long getTermsCount()
                           throws IOException
        Return the number of unique terms contained in this query, if known up-front. If not known, -1 will be returned.
        Throws:
        IOException
      • 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.
        Specified by:
        hashCode in class Query
        See Also:
        Query.equals(Object)
      • equals

        public boolean equals​(Object other)
        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.

        Specified by:
        equals in class Query
        See Also:
        Query.sameClassAs(Object), Query.classHash()