public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQueryBuilder>
MoreLikeThisQueryBuilder.Item
.Modifier and Type | Class and Description |
---|---|
static class |
MoreLikeThisQueryBuilder.Item
A single item to be used for a
MoreLikeThisQueryBuilder . |
Writeable.Reader<R>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_BOOST_TERMS |
static boolean |
DEFAULT_FAIL_ON_UNSUPPORTED_FIELDS |
static boolean |
DEFAULT_INCLUDE |
static int |
DEFAULT_MAX_DOC_FREQ |
static int |
DEFAULT_MAX_QUERY_TERMS |
static int |
DEFAULT_MAX_WORD_LENGTH |
static int |
DEFAULT_MIN_DOC_FREQ |
static int |
DEFAULT_MIN_TERM_FREQ |
static int |
DEFAULT_MIN_WORD_LENGTH |
static java.lang.String |
DEFAULT_MINIMUM_SHOULD_MATCH |
static java.lang.String |
NAME |
static ParseField |
QUERY_NAME_FIELD |
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
EMPTY_PARAMS
Constructor and Description |
---|
MoreLikeThisQueryBuilder(StreamInput in)
Read from a stream.
|
MoreLikeThisQueryBuilder(java.lang.String[] likeTexts,
MoreLikeThisQueryBuilder.Item[] likeItems)
Constructs a new more like this query which uses the "_all" field.
|
MoreLikeThisQueryBuilder(java.lang.String[] fields,
java.lang.String[] likeTexts,
MoreLikeThisQueryBuilder.Item[] likeItems)
Sets the field names that will be used when generating the 'More Like This' query.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
analyzer() |
MoreLikeThisQueryBuilder |
analyzer(java.lang.String analyzer)
The analyzer that will be used to analyze the text.
|
float |
boostTerms() |
MoreLikeThisQueryBuilder |
boostTerms(float boostTerms)
Sets the boost factor to use when boosting terms.
|
protected boolean |
doEquals(MoreLikeThisQueryBuilder other)
Indicates whether some other
QueryBuilder object of the same type is "equal to" this one. |
protected int |
doHashCode() |
protected QueryBuilder<?> |
doRewrite(QueryRewriteContext queryRewriteContext) |
protected org.apache.lucene.search.Query |
doToQuery(QueryShardContext context) |
protected void |
doWriteTo(StreamOutput out) |
protected void |
doXContent(XContentBuilder builder,
ToXContent.Params params) |
boolean |
failOnUnsupportedField() |
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.
|
java.lang.String[] |
fields() |
static MoreLikeThisQueryBuilder |
fromXContent(QueryParseContext parseContext) |
java.lang.String |
getWriteableName()
Returns the name of the writeable object
|
static MoreLikeThisQueryBuilder.Item[] |
ids(java.lang.String... ids)
Deprecated.
construct the items array externally and use it in the constructor / setter
|
boolean |
include() |
MoreLikeThisQueryBuilder |
include(boolean include)
Whether to include the input documents.
|
MoreLikeThisQueryBuilder.Item[] |
likeItems() |
java.lang.String[] |
likeTexts() |
int |
maxDocFreq() |
MoreLikeThisQueryBuilder |
maxDocFreq(int maxDocFreq)
Set the maximum frequency in which words may still appear.
|
int |
maxQueryTerms() |
MoreLikeThisQueryBuilder |
maxQueryTerms(int maxQueryTerms)
Sets the maximum number of query terms that will be included in any generated query.
|
int |
maxWordLength() |
MoreLikeThisQueryBuilder |
maxWordLength(int maxWordLength)
Sets the maximum word length above which words will be ignored.
|
int |
minDocFreq() |
MoreLikeThisQueryBuilder |
minDocFreq(int minDocFreq)
Sets the frequency at which words will be ignored which do not occur in at least this
many docs.
|
java.lang.String |
minimumShouldMatch() |
MoreLikeThisQueryBuilder |
minimumShouldMatch(java.lang.String minimumShouldMatch)
Number of terms that must match the generated query expressed in the
common syntax for minimum should match.
|
int |
minTermFreq() |
MoreLikeThisQueryBuilder |
minTermFreq(int minTermFreq)
The frequency below which terms will be ignored in the source doc.
|
int |
minWordLength() |
MoreLikeThisQueryBuilder |
minWordLength(int minWordLength)
Sets the minimum word length below which words will be ignored.
|
java.lang.String[] |
stopWords() |
MoreLikeThisQueryBuilder |
stopWords(java.util.List<java.lang.String> stopWords) |
MoreLikeThisQueryBuilder |
stopWords(java.lang.String... stopWords)
Set the set of stopwords.
|
MoreLikeThisQueryBuilder |
unlike(MoreLikeThisQueryBuilder.Item[] unlikeItems)
Sets the documents from which the terms should not be selected from.
|
MoreLikeThisQueryBuilder |
unlike(java.lang.String[] unlikeTexts)
Sets the text from which the terms should not be selected from.
|
MoreLikeThisQueryBuilder.Item[] |
unlikeItems() |
java.lang.String[] |
unlikeTexts() |
addValidationError, boost, boost, convertToBytesRefIfString, convertToStringIfBytesRef, equals, getName, hashCode, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, toFilter, toQueries, toQuery, toXContent, writeQueries, writeTo
buildAsBytes, buildAsBytes, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
rewriteQuery
public static final java.lang.String NAME
public static final ParseField QUERY_NAME_FIELD
public static final int DEFAULT_MAX_QUERY_TERMS
public static final int DEFAULT_MIN_TERM_FREQ
public static final int DEFAULT_MIN_DOC_FREQ
public static final int DEFAULT_MAX_DOC_FREQ
public static final int DEFAULT_MIN_WORD_LENGTH
public static final int DEFAULT_MAX_WORD_LENGTH
public static final java.lang.String DEFAULT_MINIMUM_SHOULD_MATCH
public static final float DEFAULT_BOOST_TERMS
public static final boolean DEFAULT_INCLUDE
public static final boolean DEFAULT_FAIL_ON_UNSUPPORTED_FIELDS
public MoreLikeThisQueryBuilder(java.lang.String[] likeTexts, MoreLikeThisQueryBuilder.Item[] likeItems)
likeTexts
- the text to use when generating the 'More Like This' query.likeItems
- the documents to use when generating the 'More Like This' query.public MoreLikeThisQueryBuilder(@Nullable java.lang.String[] fields, @Nullable java.lang.String[] likeTexts, @Nullable MoreLikeThisQueryBuilder.Item[] likeItems)
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.public MoreLikeThisQueryBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
protected void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
java.io.IOException
public java.lang.String[] fields()
public java.lang.String[] likeTexts()
public MoreLikeThisQueryBuilder.Item[] likeItems()
public MoreLikeThisQueryBuilder unlike(java.lang.String[] unlikeTexts)
public java.lang.String[] unlikeTexts()
public MoreLikeThisQueryBuilder unlike(MoreLikeThisQueryBuilder.Item[] unlikeItems)
public MoreLikeThisQueryBuilder.Item[] unlikeItems()
public MoreLikeThisQueryBuilder maxQueryTerms(int maxQueryTerms)
public int maxQueryTerms()
public MoreLikeThisQueryBuilder minTermFreq(int minTermFreq)
public int minTermFreq()
public MoreLikeThisQueryBuilder minDocFreq(int minDocFreq)
public int minDocFreq()
public MoreLikeThisQueryBuilder maxDocFreq(int maxDocFreq)
public int maxDocFreq()
public MoreLikeThisQueryBuilder minWordLength(int minWordLength)
public int minWordLength()
public MoreLikeThisQueryBuilder maxWordLength(int maxWordLength)
public int maxWordLength()
public MoreLikeThisQueryBuilder stopWords(java.lang.String... 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".
public MoreLikeThisQueryBuilder stopWords(java.util.List<java.lang.String> stopWords)
public java.lang.String[] stopWords()
public MoreLikeThisQueryBuilder analyzer(java.lang.String analyzer)
public java.lang.String analyzer()
public MoreLikeThisQueryBuilder minimumShouldMatch(java.lang.String minimumShouldMatch)
public java.lang.String minimumShouldMatch()
public MoreLikeThisQueryBuilder boostTerms(float boostTerms)
public float boostTerms()
public MoreLikeThisQueryBuilder include(boolean include)
public boolean include()
public MoreLikeThisQueryBuilder failOnUnsupportedField(boolean fail)
public boolean failOnUnsupportedField()
@Deprecated public static MoreLikeThisQueryBuilder.Item[] ids(java.lang.String... ids)
ids
- the ids to convertprotected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
doXContent
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
java.io.IOException
public static MoreLikeThisQueryBuilder fromXContent(QueryParseContext parseContext) throws java.io.IOException
java.io.IOException
public java.lang.String getWriteableName()
NamedWriteable
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
doToQuery
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
java.io.IOException
protected int doHashCode()
doHashCode
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
protected boolean doEquals(MoreLikeThisQueryBuilder other)
AbstractQueryBuilder
QueryBuilder
object of the same type is "equal to" this one.doEquals
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
protected QueryBuilder<?> doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException
doRewrite
in class AbstractQueryBuilder<MoreLikeThisQueryBuilder>
java.io.IOException