Class CommonTermsQueryBuilder

  • All Implemented Interfaces:
    NamedWriteable, Writeable, ToXContent, ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>

    public class CommonTermsQueryBuilder
    extends AbstractQueryBuilder<CommonTermsQueryBuilder>
    CommonTermsQuery query is a query that executes high-frequency terms in a optional sub-query to prevent slow queries due to "common" terms like stopwords. This query basically builds 2 queries off the #add(Term) added terms where low-frequency terms are added to a required boolean clause and high-frequency terms are added to an optional boolean clause. The optional clause is only executed if the required "low-frequency' clause matches.
    • Field Detail


        public static final Operator DEFAULT_HIGH_FREQ_OCCUR

        public static final Operator DEFAULT_LOW_FREQ_OCCUR

        public static final boolean DEFAULT_DISABLE_COORD
        See Also:
        Constant Field Values
    • Constructor Detail

      • CommonTermsQueryBuilder

        public CommonTermsQueryBuilder​(java.lang.String fieldName,
                                       java.lang.Object text)
        Constructs a new common terms query.
      • CommonTermsQueryBuilder

        public CommonTermsQueryBuilder​(StreamInput in)
        Read from a stream.
    • Method Detail

      • fieldName

        public java.lang.String fieldName()
      • value

        public java.lang.Object value()
      • highFreqOperator

        public Operator highFreqOperator()
      • lowFreqOperator

        public Operator lowFreqOperator()
      • analyzer

        public CommonTermsQueryBuilder analyzer​(java.lang.String analyzer)
        Explicitly set the analyzer to use. Defaults to use explicit mapping config for the field, or, if not set, the default search analyzer.
      • analyzer

        public java.lang.String analyzer()
      • cutoffFrequency

        public CommonTermsQueryBuilder cutoffFrequency​(float cutoffFrequency)
        Sets the cutoff document frequency for high / low frequent terms. A value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term. Defaults to {@value #DEFAULT_CUTOFF_FREQ}
      • cutoffFrequency

        public float cutoffFrequency()
      • highFreqMinimumShouldMatch

        public CommonTermsQueryBuilder highFreqMinimumShouldMatch​(java.lang.String highFreqMinimumShouldMatch)
        Sets the minimum number of high frequent query terms that need to match in order to produce a hit when there are no low frequent terms.
      • highFreqMinimumShouldMatch

        public java.lang.String highFreqMinimumShouldMatch()
      • lowFreqMinimumShouldMatch

        public CommonTermsQueryBuilder lowFreqMinimumShouldMatch​(java.lang.String lowFreqMinimumShouldMatch)
        Sets the minimum number of low frequent query terms that need to match in order to produce a hit.
      • lowFreqMinimumShouldMatch

        public java.lang.String lowFreqMinimumShouldMatch()
      • getWriteableName

        public java.lang.String getWriteableName()
        Description copied from interface: NamedWriteable
        Returns the name of the writeable object