org.elasticsearch.action.mlt
Class MoreLikeThisRequest

java.lang.Object
  extended by org.elasticsearch.action.mlt.MoreLikeThisRequest
All Implemented Interfaces:
ActionRequest, Streamable

public class MoreLikeThisRequest
extends Object
implements ActionRequest

A more like this request allowing to search for documents that a "like" the provided document. The document to check against to fetched based on the index, type and id provided. Best created with Requests.moreLikeThisRequest(String).

Note, the index(), type(String) and id(String) are required.

See Also:
Client.moreLikeThis(MoreLikeThisRequest), Requests.moreLikeThisRequest(String), SearchResponse

Constructor Summary
MoreLikeThisRequest(String index)
          Constructs a new more like this request for a document that will be fetch from the provided index.
 
Method Summary
 float boostTerms()
          The boost factor to use when boosting terms.
 MoreLikeThisRequest boostTerms(float boostTerms)
          The boost factor to use when boosting terms.
 String[] fields()
          The fields of the document to use in order to find documents "like" this one.
 MoreLikeThisRequest fields(String... fields)
          The fields of the document to use in order to find documents "like" this one.
 String id()
          The id of document to load from which the "like" query will execute with.
 MoreLikeThisRequest id(String id)
          The id of document to load from which the "like" query will execute with.
 String index()
          The index to load the document from which the "like" query will run with.
 boolean listenerThreaded()
          Should the listener be called on a separate thread if needed.
 ActionRequest listenerThreaded(boolean listenerThreaded)
          Should the listener be called on a separate thread if needed.
 int maxDocFreq()
          The maximum frequency in which words may still appear.
 MoreLikeThisRequest maxDocFreq(int maxDocFreq)
          The maximum frequency in which words may still appear.
 int maxQueryTerms()
          The maximum number of query terms that will be included in any generated query.
 MoreLikeThisRequest maxQueryTerms(int maxQueryTerms)
          The maximum number of query terms that will be included in any generated query.
 int maxWordLen()
          The maximum word length above which words will be ignored.
 MoreLikeThisRequest maxWordLen(int maxWordLen)
          The maximum word length above which words will be ignored.
 int minDocFreq()
          The frequency at which words will be ignored which do not occur in at least this many docs.
 MoreLikeThisRequest minDocFreq(int minDocFreq)
          The frequency at which words will be ignored which do not occur in at least this many docs.
 int minTermFreq()
          The frequency below which terms will be ignored in the source doc.
 MoreLikeThisRequest minTermFreq(int minTermFreq)
          The frequency below which terms will be ignored in the source doc.
 int minWordLen()
          The minimum word length below which words will be ignored.
 MoreLikeThisRequest minWordLen(int minWordLen)
          The minimum word length below which words will be ignored.
 float percentTermsToMatch()
          The percent of the terms to match for each field.
 MoreLikeThisRequest percentTermsToMatch(float percentTermsToMatch)
          The percent of the terms to match for each field.
 void readFrom(StreamInput in)
           
 int searchFrom()
           
 MoreLikeThisRequest searchFrom(int from)
          From which search result set to return.
 String[] searchIndices()
          The indices the resulting mlt query will run against.
 MoreLikeThisRequest searchIndices(String... searchIndices)
          The indices the resulting mlt query will run against.
 String searchQueryHint()
          Optional search query hint.
 MoreLikeThisRequest searchQueryHint(String searchQueryHint)
          Optional search query hint.
 Scroll searchScroll()
          An optional search scroll request to be able to continue and scroll the search operation.
 MoreLikeThisRequest searchScroll(Scroll searchScroll)
          An optional search scroll request to be able to continue and scroll the search operation.
 int searchSize()
           
 MoreLikeThisRequest searchSize(int size)
          The number of documents to return, defaults to 10.
 BytesReference searchSource()
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(byte[] searchSource)
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(byte[] searchSource, int offset, int length, boolean unsafe)
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(BytesReference searchSource, boolean unsafe)
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(Map searchSource)
           
 MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder)
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(String searchSource)
          An optional search source request allowing to control the search request for the more like this documents.
 MoreLikeThisRequest searchSource(XContentBuilder builder)
           
 boolean searchSourceUnsafe()
           
 SearchType searchType()
          The search type of the mlt search query.
 MoreLikeThisRequest searchType(SearchType searchType)
          The search type of the mlt search query.
 MoreLikeThisRequest searchType(String searchType)
          The search type of the mlt search query.
 String[] searchTypes()
          The types the resulting mlt query will run against.
 MoreLikeThisRequest searchTypes(String... searchTypes)
          The types the resulting mlt query will run against.
 String[] stopWords()
          Any word in this set is considered "uninteresting" and ignored.
 MoreLikeThisRequest stopWords(String... stopWords)
          Any word in this set is considered "uninteresting" and ignored.
 String type()
          The type of document to load from which the "like" query will rutn with.
 MoreLikeThisRequest type(String type)
          The type of document to load from which the "like" query will execute with.
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoreLikeThisRequest

public MoreLikeThisRequest(String index)
Constructs a new more like this request for a document that will be fetch from the provided index. Use type(String) and id(String) to specify the document to load.

Method Detail

index

public String index()
The index to load the document from which the "like" query will run with.


type

public String type()
The type of document to load from which the "like" query will rutn with.


type

@Required
public MoreLikeThisRequest type(String type)
The type of document to load from which the "like" query will execute with.


id

public String id()
The id of document to load from which the "like" query will execute with.


id

@Required
public MoreLikeThisRequest id(String id)
The id of document to load from which the "like" query will execute with.


fields

public String[] fields()
The fields of the document to use in order to find documents "like" this one. Defaults to run against all the document fields.


fields

public MoreLikeThisRequest fields(String... fields)
The fields of the document to use in order to find documents "like" this one. Defaults to run against all the document fields.


percentTermsToMatch

public MoreLikeThisRequest percentTermsToMatch(float percentTermsToMatch)
The percent of the terms to match for each field. Defaults to 0.3f.


percentTermsToMatch

public float percentTermsToMatch()
The percent of the terms to match for each field. Defaults to 0.3f.


minTermFreq

public MoreLikeThisRequest minTermFreq(int minTermFreq)
The frequency below which terms will be ignored in the source doc. Defaults to 2.


minTermFreq

public int minTermFreq()
The frequency below which terms will be ignored in the source doc. Defaults to 2.


maxQueryTerms

public MoreLikeThisRequest maxQueryTerms(int maxQueryTerms)
The maximum number of query terms that will be included in any generated query. Defaults to 25.


maxQueryTerms

public int maxQueryTerms()
The maximum number of query terms that will be included in any generated query. Defaults to 25.


stopWords

public MoreLikeThisRequest stopWords(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".

Defaults to no stop words.


stopWords

public 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".

Defaults to no stop words.


minDocFreq

public MoreLikeThisRequest minDocFreq(int minDocFreq)
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()
The frequency at which words will be ignored which do not occur in at least this many docs. Defaults to 5.


maxDocFreq

public MoreLikeThisRequest maxDocFreq(int maxDocFreq)
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()
The maximum frequency in which words may still appear. Words that appear in more than this many docs will be ignored. Defaults to unbounded.


minWordLen

public MoreLikeThisRequest minWordLen(int minWordLen)
The minimum word length below which words will be ignored. Defaults to 0.


minWordLen

public int minWordLen()
The minimum word length below which words will be ignored. Defaults to 0.


maxWordLen

public MoreLikeThisRequest maxWordLen(int maxWordLen)
The maximum word length above which words will be ignored. Defaults to unbounded.


maxWordLen

public int maxWordLen()
The maximum word length above which words will be ignored. Defaults to unbounded.


boostTerms

public MoreLikeThisRequest boostTerms(float boostTerms)
The boost factor to use when boosting terms. Defaults to 1.


boostTerms

public float boostTerms()
The boost factor to use when boosting terms. Defaults to 1.


searchSource

public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder)
An optional search source request allowing to control the search request for the more like this documents.


searchSource

public MoreLikeThisRequest searchSource(String searchSource)
An optional search source request allowing to control the search request for the more like this documents.


searchSource

public MoreLikeThisRequest searchSource(Map searchSource)

searchSource

public MoreLikeThisRequest searchSource(XContentBuilder builder)

searchSource

public MoreLikeThisRequest searchSource(byte[] searchSource)
An optional search source request allowing to control the search request for the more like this documents.


searchSource

public MoreLikeThisRequest searchSource(byte[] searchSource,
                                        int offset,
                                        int length,
                                        boolean unsafe)
An optional search source request allowing to control the search request for the more like this documents.


searchSource

public MoreLikeThisRequest searchSource(BytesReference searchSource,
                                        boolean unsafe)
An optional search source request allowing to control the search request for the more like this documents.


searchSource

public BytesReference searchSource()
An optional search source request allowing to control the search request for the more like this documents.


searchSourceUnsafe

public boolean searchSourceUnsafe()

searchType

public MoreLikeThisRequest searchType(SearchType searchType)
The search type of the mlt search query.


searchType

public MoreLikeThisRequest searchType(String searchType)
                               throws ElasticSearchIllegalArgumentException
The search type of the mlt search query.

Throws:
ElasticSearchIllegalArgumentException

searchType

public SearchType searchType()
The search type of the mlt search query.


searchIndices

public MoreLikeThisRequest searchIndices(String... searchIndices)
The indices the resulting mlt query will run against. If not set, will run against the index the document was fetched from.


searchIndices

public String[] searchIndices()
The indices the resulting mlt query will run against. If not set, will run against the index the document was fetched from.


searchTypes

public MoreLikeThisRequest searchTypes(String... searchTypes)
The types the resulting mlt query will run against. If not set, will run against the type of the document fetched.


searchTypes

public String[] searchTypes()
The types the resulting mlt query will run against. If not set, will run against the type of the document fetched.


searchQueryHint

public MoreLikeThisRequest searchQueryHint(String searchQueryHint)
Optional search query hint.


searchQueryHint

public String searchQueryHint()
Optional search query hint.


searchScroll

public MoreLikeThisRequest searchScroll(Scroll searchScroll)
An optional search scroll request to be able to continue and scroll the search operation.


searchScroll

public Scroll searchScroll()
An optional search scroll request to be able to continue and scroll the search operation.


searchSize

public MoreLikeThisRequest searchSize(int size)
The number of documents to return, defaults to 10.


searchSize

public int searchSize()

searchFrom

public MoreLikeThisRequest searchFrom(int from)
From which search result set to return.


searchFrom

public int searchFrom()

validate

public ActionRequestValidationException validate()
Specified by:
validate in interface ActionRequest

listenerThreaded

public boolean listenerThreaded()
Should the listener be called on a separate thread if needed.

Specified by:
listenerThreaded in interface ActionRequest

listenerThreaded

public ActionRequest listenerThreaded(boolean listenerThreaded)
Should the listener be called on a separate thread if needed.

Specified by:
listenerThreaded in interface ActionRequest

readFrom

public void readFrom(StreamInput in)
              throws IOException
Specified by:
readFrom in interface Streamable
Throws:
IOException

writeTo

public void writeTo(StreamOutput out)
             throws IOException
Specified by:
writeTo in interface Streamable
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.