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 facets 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
Constructs a new search request starting from the provided request, meaning that it will inherit its headers and context
|
SearchRequest(SearchRequest
Copy constructor that creates a new search request that is a copy of the one provided as an argument.
|
SearchRequest(String
Constructs a new search request against the indices.
|
SearchRequest(String
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
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(Map
|
SearchRequest |
extraSource(SearchSourceBuilder
Allows to provide additional source that will be used as well.
|
SearchRequest |
extraSource(String
Allows to provide additional source that will use used as well.
|
SearchRequest |
extraSource(XContentBuilder
|
String |
indices()
The indices
|
SearchRequest |
indices(String
Sets the indices the search will be executed on.
|
IndicesOptions |
indicesOptions()
Returns the indices options used to resolve indices.
|
SearchRequest |
indicesOptions(IndicesOptions
|
String |
preference()
|
SearchRequest |
preference(String
Sets the preference to execute the search.
|
Boolean |
queryCache()
|
SearchRequest |
queryCache(Boolean
Sets if this request should use the query cache or not, assuming that it can (for example, if "now" is used, it will never be cached).
|
void |
readFrom(StreamInput
|
String |
routing()
A comma separated list of routing values to control the shards the search will be executed on.
|
SearchRequest |
routing(String
The routing values to control the shards that the search will be executed on.
|
SearchRequest |
routing(String
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
If set, will enable scrolling of the search request.
|
SearchRequest |
scroll(String
If set, will enable scrolling of the search request for the specified timeout.
|
SearchRequest |
scroll(TimeValue
If set, will enable scrolling of the search request for the specified timeout.
|
SearchType |
searchType()
The tye of search to execute.
|
SearchRequest |
searchType(SearchType
The search type to execute, defaults to
SearchType.
|
SearchRequest |
searchType(String
The a string representation search type to execute, defaults to
SearchType.
|
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
The search source to execute.
|
SearchRequest |
source(Map
The source of the search request in the form of a map.
|
SearchRequest |
source(SearchSourceBuilder
The source of the search request.
|
SearchRequest |
source(String
The source of the search request.
|
SearchRequest |
source(XContentBuilder
|
String |
templateName()
The name of the stored template
|
void |
templateName(String
The name of the stored template
|
Map |
templateParams()
Template parameters used for rendering
|
void |
templateParams(Map
Template parameters used for rendering
|
BytesReference |
templateSource()
The search source template to execute.
|
SearchRequest |
templateSource(BytesReference
Allows to provide template as source.
|
SearchRequest |
templateSource(String
The template of the search request.
|
ScriptService |
templateType()
The name of the stored template
|
void |
templateType(ScriptService
|
String |
types()
The document types to execute the search against.
|
SearchRequest |
types(String
The document types to execute the search against.
|
ActionRequestValidationException |
validate()
|
void |
writeTo(StreamOutput
|
listenerThreaded, listenerThreadedputHeader, remoteAddress, remoteAddresscontextSize, copyContextAndHeadersFrom, copyContextFrom, copyHeadersFrom, getContext, getFromContext, getFromContext, getHeader, getHeaders, hasHeader, hasInContext, isContextEmpty, putAllInContext, putInContextpublic static final IndicesOptionsDEFAULT_INDICES_OPTIONS
public SearchRequest()
public SearchRequest(SearchRequestsearchRequest, ActionRequest originalRequest)
public SearchRequest(ActionRequestrequest)
public SearchRequest(String... indices)
public SearchRequest(String[] indices, byte[] source)
public ActionRequestValidationExceptionvalidate()
public SearchRequestindices(String ... indices)
public IndicesOptionsindicesOptions()
IndicesRequest
public SearchRequestindicesOptions(IndicesOptions indicesOptions)
public String[] types()
public SearchRequesttypes(String ... types)
public Stringrouting()
public SearchRequestrouting(String routing)
public SearchRequestrouting(String ... routings)
public SearchRequestpreference(String preference)
public Stringpreference()
public SearchRequestsearchType(SearchType searchType)
SearchType.DEFAULT .
public SearchRequestsearchType(String searchType) throws ElasticsearchIllegalArgumentException
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 SearchRequestsource(SearchSourceBuilder sourceBuilder)
public SearchRequestsource(String source)
source(byte[]) or
source(org.elasticsearch.search.builder.SearchSourceBuilder).
public SearchRequestsource(Map source)
public SearchRequestsource(XContentBuilder builder)
public SearchRequestsource(byte[] source)
public SearchRequestsource(byte[] source, int offset, int length)
public SearchRequestsource(BytesReference source)
public BytesReferencesource()
public BytesReferencetemplateSource()
public SearchRequestextraSource(SearchSourceBuilder sourceBuilder)
public SearchRequestextraSource(Map extraSource)
public SearchRequestextraSource(XContentBuilder builder)
public SearchRequestextraSource(String source)
public SearchRequestextraSource(byte[] source)
public SearchRequestextraSource(byte[] source, int offset, int length)
public SearchRequestextraSource(BytesReference source)
public SearchRequesttemplateSource(BytesReference template)
public SearchRequesttemplateSource(String template)
public void templateName(StringtemplateName)
public void templateType(ScriptService.ScriptType templateType)
public void templateParams(Map<String ,Object > params)
public StringtemplateName()
public ScriptService.ScriptType templateType()
public BytesReferenceextraSource()
public SearchTypesearchType()
public String[] indices()
public Scrollscroll()
public SearchRequestscroll(Scroll scroll)
public SearchRequestscroll(TimeValue keepAlive)
public SearchRequestscroll(String keepAlive)
public SearchRequestqueryCache(Boolean queryCache)
public BooleanqueryCache()
public void readFrom(StreamInputin) throws IOException
readFrom in interface
Streamable
readFrom in class
ActionRequest<SearchRequest>
IOException
public void writeTo(StreamOutputout) throws IOException
writeTo in interface
Streamable
writeTo in class
ActionRequest<SearchRequest>
IOException