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 |
static int |
DEFAULT_PRE_FILTER_SHARD_SIZE |
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 |
getBatchedReduceSize()
Returns the number of shard results that should be reduced at once on the coordinating node.
|
int |
getMaxConcurrentShardRequests()
Returns the number of shard requests that should be executed concurrently.
|
int |
getPreFilterShardSize()
Returns a threshold that enforces a pre-filter roundtrip to pre-filter search shards based on query rewriting if the number of shards
the search request expands to exceeds the threshold.
|
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 . |
void |
setBatchedReduceSize(int batchedReduceSize)
Sets the number of shard results that should be reduced at once on the coordinating node.
|
void |
setMaxConcurrentShardRequests(int maxConcurrentShardRequests)
Sets the number of shard requests that should be executed concurrently.
|
void |
setPreFilterShardSize(int preFilterShardSize)
Sets a threshold that enforces a pre-filter roundtrip to pre-filter search shards based on query rewriting if the number of shards
the search request expands to exceeds the threshold.
|
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
getParentTask, setParentTask
remoteAddress, remoteAddress
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getDescription, setParentTask
public static final int DEFAULT_PRE_FILTER_SHARD_SIZE
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 void setBatchedReduceSize(int batchedReduceSize)
public int getBatchedReduceSize()
public int getMaxConcurrentShardRequests()
public void setMaxConcurrentShardRequests(int maxConcurrentShardRequests)
public void setPreFilterShardSize(int preFilterShardSize)
public int getPreFilterShardSize()
public boolean isSuggestOnly()
public Task createTask(long id, java.lang.String type, java.lang.String action, TaskId parentTaskId)
TaskAwareRequest
createTask
in interface TaskAwareRequest
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