public final class SearchRequest extends ActionRequest implements IndicesRequest.Replaceable
Requests.searchRequest(String...)
.
Note, the search source(org.elasticsearch.search.builder.SearchSourceBuilder)
is required. The search source is the different search options, including aggregations and such.
TransportRequest.Empty
IndicesRequest.Replaceable
Modifier and Type | Field and Description |
---|---|
static IndicesOptions |
DEFAULT_INDICES_OPTIONS |
Constructor and Description |
---|
SearchRequest() |
SearchRequest(java.lang.String... indices)
Constructs a new search request against the indices.
|
SearchRequest(java.lang.String[] indices,
SearchSourceBuilder source)
Constructs a new search request against the provided indices with the given search source.
|
Modifier and Type | Method and Description |
---|---|
Task |
createTask(long id,
java.lang.String type,
java.lang.String action,
TaskId parentTaskId)
Returns the task object that should be used to keep track of the processing of the request.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
java.lang.String[] |
indices()
The indices
|
SearchRequest |
indices(java.lang.String... indices)
Sets the indices the search will be executed on.
|
IndicesOptions |
indicesOptions()
Returns the indices options used to resolve indices.
|
SearchRequest |
indicesOptions(IndicesOptions indicesOptions) |
boolean |
isSuggestOnly() |
java.lang.String |
preference() |
SearchRequest |
preference(java.lang.String preference)
Sets the preference to execute the search.
|
void |
readFrom(StreamInput in)
Set this object's fields from a StreamInput.
|
java.lang.Boolean |
requestCache() |
SearchRequest |
requestCache(java.lang.Boolean requestCache)
Sets if this request should use the request cache or not, assuming that it can (for
example, if "now" is used, it will never be cached).
|
java.lang.String |
routing()
A comma separated list of routing values to control the shards the search will be executed on.
|
SearchRequest |
routing(java.lang.String... routings)
The routing values to control the shards that the search will be executed on.
|
SearchRequest |
routing(java.lang.String routing)
A comma separated list of routing values to control the shards the search will be executed on.
|
Scroll |
scroll()
If set, will enable scrolling of the search request.
|
SearchRequest |
scroll(Scroll scroll)
If set, will enable scrolling of the search request.
|
SearchRequest |
scroll(java.lang.String keepAlive)
If set, will enable scrolling of the search request for the specified timeout.
|
SearchRequest |
scroll(TimeValue keepAlive)
If set, will enable scrolling of the search request for the specified timeout.
|
SearchType |
searchType()
The tye of search to execute.
|
SearchRequest |
searchType(SearchType searchType)
The search type to execute, defaults to
SearchType.DEFAULT . |
SearchRequest |
searchType(java.lang.String searchType)
The a string representation search type to execute, defaults to
SearchType.DEFAULT . |
SearchSourceBuilder |
source()
The search source to execute.
|
SearchRequest |
source(SearchSourceBuilder sourceBuilder)
The source of the search request.
|
java.lang.String |
toString() |
java.lang.String[] |
types()
The document types to execute the search against.
|
SearchRequest |
types(java.lang.String... types)
The document types to execute the search against.
|
ActionRequestValidationException |
validate() |
void |
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.
|
getShouldStoreResult
getDescription, getParentTask, setParentTask, setParentTask
remoteAddress, remoteAddress
public static final IndicesOptions DEFAULT_INDICES_OPTIONS
public SearchRequest()
public SearchRequest(java.lang.String... indices)
public SearchRequest(java.lang.String[] indices, SearchSourceBuilder source)
public ActionRequestValidationException validate()
validate
in class ActionRequest
public SearchRequest indices(java.lang.String... indices)
indices
in interface IndicesRequest.Replaceable
public IndicesOptions indicesOptions()
IndicesRequest
indicesOptions
in interface IndicesRequest
public SearchRequest indicesOptions(IndicesOptions indicesOptions)
public java.lang.String[] types()
public SearchRequest types(java.lang.String... types)
public java.lang.String routing()
public SearchRequest routing(java.lang.String routing)
public SearchRequest routing(java.lang.String... routings)
public SearchRequest preference(java.lang.String preference)
public java.lang.String preference()
public SearchRequest searchType(SearchType searchType)
SearchType.DEFAULT
.public SearchRequest searchType(java.lang.String searchType)
SearchType.DEFAULT
. Can be
one of "dfs_query_then_fetch"/"dfsQueryThenFetch", "dfs_query_and_fetch"/"dfsQueryAndFetch",
"query_then_fetch"/"queryThenFetch", and "query_and_fetch"/"queryAndFetch".public SearchRequest source(SearchSourceBuilder sourceBuilder)
public SearchSourceBuilder source()
public SearchType searchType()
public java.lang.String[] indices()
indices
in interface IndicesRequest
public Scroll scroll()
public SearchRequest scroll(Scroll scroll)
public SearchRequest scroll(TimeValue keepAlive)
public SearchRequest scroll(java.lang.String keepAlive)
public SearchRequest requestCache(java.lang.Boolean requestCache)
public java.lang.Boolean requestCache()
public boolean isSuggestOnly()
public Task createTask(long id, java.lang.String type, java.lang.String action, TaskId parentTaskId)
TransportRequest
createTask
in class TransportRequest
public void readFrom(StreamInput in) throws java.io.IOException
Streamable
readFrom
in interface Streamable
readFrom
in class ActionRequest
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Streamable
writeTo
in interface Streamable
writeTo
in class ActionRequest
java.io.IOException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object