public class SearchRequest extends ActionRequest<SearchRequest> 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.
There is an option to specify an addition search source using the extraSource(org.elasticsearch.search.builder.SearchSourceBuilder)
.
TransportRequest.Empty
IndicesRequest.Replaceable
Modifier and Type | Field and Description |
---|---|
static IndicesOptions |
DEFAULT_INDICES_OPTIONS |
headers
Constructor and Description |
---|
SearchRequest() |
SearchRequest(ActionRequest request)
Constructs a new search request starting from the provided request, meaning that it will
inherit its headers and context
|
SearchRequest(SearchRequest searchRequest,
ActionRequest originalRequest)
Copy constructor that creates a new search request that is a copy of the one provided as an argument.
|
SearchRequest(String... indices)
Constructs a new search request against the indices.
|
SearchRequest(String[] indices,
byte[] source)
Constructs a new search request against the provided indices with the given search source.
|
Modifier and Type | Method and Description |
---|---|
BytesReference |
extraSource()
Additional search source to execute.
|
SearchRequest |
extraSource(byte[] source)
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(byte[] source,
int offset,
int length)
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(BytesReference source)
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(Map extraSource) |
SearchRequest |
extraSource(SearchSourceBuilder sourceBuilder)
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(String source)
Allows to provide additional source that will use used as well.
|
SearchRequest |
extraSource(XContentBuilder builder) |
String[] |
indices()
The indices
|
SearchRequest |
indices(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) |
String |
preference() |
SearchRequest |
preference(String preference)
Sets the preference to execute the search.
|
void |
readFrom(StreamInput in) |
Boolean |
requestCache() |
SearchRequest |
requestCache(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).
|
String |
routing()
A comma separated list of routing values to control the shards the search will be executed on.
|
SearchRequest |
routing(String... routings)
The routing values to control the shards that the search will be executed on.
|
SearchRequest |
routing(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(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(String searchType)
The a string representation search type to execute, defaults to
SearchType.DEFAULT . |
BytesReference |
source()
The search source to execute.
|
SearchRequest |
source(byte[] source)
The search source to execute.
|
SearchRequest |
source(byte[] source,
int offset,
int length)
The search source to execute.
|
SearchRequest |
source(BytesReference source)
The search source to execute.
|
SearchRequest |
source(Map source)
The source of the search request in the form of a map.
|
SearchRequest |
source(SearchSourceBuilder sourceBuilder)
The source of the search request.
|
SearchRequest |
source(String source)
The source of the search request.
|
SearchRequest |
source(XContentBuilder builder) |
Template |
template()
The stored template
|
void |
template(Template template)
The stored template
|
String |
templateName()
Deprecated.
use
template() instead. |
void |
templateName(String templateName)
Deprecated.
use
template(Template) instead. |
Map<String,Object> |
templateParams()
Deprecated.
use
template() instead. |
void |
templateParams(Map<String,Object> params)
Deprecated.
use
template(Template) instead. |
BytesReference |
templateSource()
The search source template to execute.
|
SearchRequest |
templateSource(BytesReference template)
Allows to provide template as source.
|
SearchRequest |
templateSource(String template)
The template of the search request.
|
ScriptService.ScriptType |
templateType()
Deprecated.
use
template() instead. |
void |
templateType(ScriptService.ScriptType templateType)
Deprecated.
use
template(Template) instead. |
String[] |
types()
The document types to execute the search against.
|
SearchRequest |
types(String... types)
The document types to execute the search against.
|
ActionRequestValidationException |
validate() |
void |
writeTo(StreamOutput out) |
createTask, getDescription
remoteAddress, remoteAddress
contextSize, copyContextAndHeadersFrom, copyContextFrom, copyHeadersFrom, getContext, getFromContext, getFromContext, getHeader, getHeaders, hasHeader, hasInContext, isContextEmpty, putAllInContext, putHeader, putInContext
public static final IndicesOptions DEFAULT_INDICES_OPTIONS
public SearchRequest()
public SearchRequest(SearchRequest searchRequest, ActionRequest originalRequest)
public SearchRequest(ActionRequest request)
public SearchRequest(String... indices)
public SearchRequest(String[] indices, byte[] source)
public ActionRequestValidationException validate()
validate
in class ActionRequest<SearchRequest>
public SearchRequest indices(String... indices)
indices
in interface IndicesRequest.Replaceable
public IndicesOptions indicesOptions()
IndicesRequest
indicesOptions
in interface IndicesRequest
public SearchRequest indicesOptions(IndicesOptions indicesOptions)
public String[] types()
public SearchRequest types(String... types)
public String routing()
public SearchRequest routing(String routing)
public SearchRequest routing(String... routings)
public SearchRequest preference(String preference)
public String preference()
public SearchRequest searchType(SearchType searchType)
SearchType.DEFAULT
.public SearchRequest searchType(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 SearchRequest source(String source)
source(byte[])
or
source(org.elasticsearch.search.builder.SearchSourceBuilder)
.public SearchRequest source(Map source)
public SearchRequest source(XContentBuilder builder)
public SearchRequest source(byte[] source)
public SearchRequest source(byte[] source, int offset, int length)
public SearchRequest source(BytesReference source)
public BytesReference source()
public BytesReference templateSource()
public SearchRequest extraSource(SearchSourceBuilder sourceBuilder)
public SearchRequest extraSource(Map extraSource)
public SearchRequest extraSource(XContentBuilder builder)
public SearchRequest extraSource(String source)
public SearchRequest extraSource(byte[] source)
public SearchRequest extraSource(byte[] source, int offset, int length)
public SearchRequest extraSource(BytesReference source)
public SearchRequest templateSource(BytesReference template)
public SearchRequest templateSource(String template)
public void template(Template template)
public Template template()
@Deprecated public void templateName(String templateName)
template(Template)
instead.@Deprecated public void templateType(ScriptService.ScriptType templateType)
template(Template)
instead.@Deprecated public void templateParams(Map<String,Object> params)
template(Template)
instead.@Deprecated public String templateName()
template()
instead.@Deprecated public ScriptService.ScriptType templateType()
template()
instead.@Deprecated public Map<String,Object> templateParams()
template()
instead.public BytesReference extraSource()
public SearchType searchType()
public String[] indices()
indices
in interface IndicesRequest
public Scroll scroll()
public SearchRequest scroll(Scroll scroll)
public SearchRequest scroll(TimeValue keepAlive)
public SearchRequest scroll(String keepAlive)
public SearchRequest requestCache(Boolean requestCache)
public Boolean requestCache()
public void readFrom(StreamInput in) throws IOException
readFrom
in interface Streamable
readFrom
in class ActionRequest<SearchRequest>
IOException
public void writeTo(StreamOutput out) throws IOException
writeTo
in interface Streamable
writeTo
in class ActionRequest<SearchRequest>
IOException
Copyright © 2009–2016. All rights reserved.