Class MoreLikeThisQueryBuilder

    • Constructor Detail

      • MoreLikeThisQueryBuilder

        public MoreLikeThisQueryBuilder​(java.lang.String[] likeTexts,
                                        MoreLikeThisQueryBuilder.Item[] likeItems)
        Constructs a new more like this query which uses the default search field.
        Parameters:
        likeTexts - the text to use when generating the 'More Like This' query.
        likeItems - the documents to use when generating the 'More Like This' query.
      • MoreLikeThisQueryBuilder

        public MoreLikeThisQueryBuilder​(@Nullable
                                        java.lang.String[] fields,
                                        @Nullable
                                        java.lang.String[] likeTexts,
                                        @Nullable
                                        MoreLikeThisQueryBuilder.Item[] likeItems)
        Sets the field names that will be used when generating the 'More Like This' query.
        Parameters:
        fields - the field names that will be used when generating the 'More Like This' query.
        likeTexts - the text to use when generating the 'More Like This' query.
        likeItems - the documents to use when generating the 'More Like This' query.
      • MoreLikeThisQueryBuilder

        public MoreLikeThisQueryBuilder​(StreamInput in)
                                 throws java.io.IOException
        Read from a stream.
        Throws:
        java.io.IOException
    • Method Detail

      • fields

        public java.lang.String[] fields()
      • likeTexts

        public java.lang.String[] likeTexts()
      • unlike

        public MoreLikeThisQueryBuilder unlike​(java.lang.String[] unlikeTexts)
        Sets the text from which the terms should not be selected from.
      • unlikeTexts

        public java.lang.String[] unlikeTexts()
      • maxQueryTerms

        public MoreLikeThisQueryBuilder maxQueryTerms​(int maxQueryTerms)
        Sets the maximum number of query terms that will be included in any generated query. Defaults to 25.
      • maxQueryTerms

        public int maxQueryTerms()
      • minTermFreq

        public MoreLikeThisQueryBuilder minTermFreq​(int minTermFreq)
        The frequency below which terms will be ignored in the source doc. The default frequency is 2.
      • minTermFreq

        public int minTermFreq()
      • minDocFreq

        public MoreLikeThisQueryBuilder minDocFreq​(int minDocFreq)
        Sets the frequency at which words will be ignored which do not occur in at least this many docs. Defaults to 5.
      • minDocFreq

        public int minDocFreq()
      • maxDocFreq

        public MoreLikeThisQueryBuilder maxDocFreq​(int maxDocFreq)
        Set the maximum frequency in which words may still appear. Words that appear in more than this many docs will be ignored. Defaults to unbounded.
      • maxDocFreq

        public int maxDocFreq()
      • minWordLength

        public MoreLikeThisQueryBuilder minWordLength​(int minWordLength)
        Sets the minimum word length below which words will be ignored. Defaults to 0.
      • minWordLength

        public int minWordLength()
      • maxWordLength

        public MoreLikeThisQueryBuilder maxWordLength​(int maxWordLength)
        Sets the maximum word length above which words will be ignored. Defaults to unbounded (0).
      • maxWordLength

        public int maxWordLength()
      • stopWords

        public MoreLikeThisQueryBuilder stopWords​(java.lang.String... stopWords)
        Set the set of stopwords.

        Any word in this set is considered "uninteresting" and ignored. Even if your Analyzer allows stopwords, you might want to tell the MoreLikeThis code to ignore them, as for the purposes of document similarity it seems reasonable to assume that "a stop word is never interesting".

      • stopWords

        public java.lang.String[] stopWords()
      • analyzer

        public MoreLikeThisQueryBuilder analyzer​(java.lang.String analyzer)
        The analyzer that will be used to analyze the text. Defaults to the analyzer associated with the field.
      • analyzer

        public java.lang.String analyzer()
      • minimumShouldMatch

        public java.lang.String minimumShouldMatch()
      • boostTerms

        public MoreLikeThisQueryBuilder boostTerms​(float boostTerms)
        Sets the boost factor to use when boosting terms. Defaults to 0 (deactivated).
      • boostTerms

        public float boostTerms()
      • include

        public MoreLikeThisQueryBuilder include​(boolean include)
        Whether to include the input documents. Defaults to false
      • include

        public boolean include()
      • failOnUnsupportedField

        public MoreLikeThisQueryBuilder failOnUnsupportedField​(boolean fail)
        Whether to fail or return no result when this query is run against a field which is not supported such as binary/numeric fields.
      • failOnUnsupportedField

        public boolean failOnUnsupportedField()
      • isTypeless

        public boolean isTypeless()
      • getWriteableName

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