Class SearchRequest.Builder
- All Implemented Interfaces:
WithJson<SearchRequest.Builder>
,ObjectBuilder<SearchRequest>
- Enclosing class:
- SearchRequest
SearchRequest
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal SearchRequest.Builder
aggregations
(String key, Aggregation value) API name:aggregations
final SearchRequest.Builder
API name:aggregations
final SearchRequest.Builder
aggregations
(Map<String, Aggregation> map) API name:aggregations
final SearchRequest.Builder
allowNoIndices
(Boolean value) Whether to ignore if a wildcard indices expression resolves into no concrete indices.final SearchRequest.Builder
allowPartialSearchResults
(Boolean value) Indicate if an error should be returned if there is a partial search failure or timeoutfinal SearchRequest.Builder
The analyzer to use for the query stringfinal SearchRequest.Builder
analyzeWildcard
(Boolean value) Specify whether wildcard and prefix queries should be analyzed (default: false)final SearchRequest.Builder
batchedReduceSize
(Long value) The number of shard results that should be reduced at once on the coordinating node.build()
Builds aSearchRequest
.final SearchRequest.Builder
ccsMinimizeRoundtrips
(Boolean value) Indicates whether network round-trips should be minimized as part of cross-cluster search requests executionfinal SearchRequest.Builder
collapse
(FieldCollapse value) API name:collapse
final SearchRequest.Builder
API name:collapse
final SearchRequest.Builder
defaultOperator
(Operator value) The default operator for query string query (AND or OR)final SearchRequest.Builder
The field to use as default where no field prefix is given in the query stringfinal SearchRequest.Builder
docvalueFields
(FieldAndFormat value, FieldAndFormat... values) Array of wildcard (*) patterns.final SearchRequest.Builder
Array of wildcard (*) patterns.final SearchRequest.Builder
docvalueFields
(List<FieldAndFormat> list) Array of wildcard (*) patterns.final SearchRequest.Builder
expandWildcards
(ExpandWildcard value, ExpandWildcard... values) Whether to expand wildcard expression to concrete indices that are open, closed or both.final SearchRequest.Builder
expandWildcards
(List<ExpandWildcard> list) Whether to expand wildcard expression to concrete indices that are open, closed or both.final SearchRequest.Builder
If true, returns detailed information about score computation as part of a hit.final SearchRequest.Builder
Configuration of search extensions defined by Elasticsearch plugins.final SearchRequest.Builder
Configuration of search extensions defined by Elasticsearch plugins.final SearchRequest.Builder
fields
(FieldAndFormat value, FieldAndFormat... values) Array of wildcard (*) patterns.final SearchRequest.Builder
Array of wildcard (*) patterns.final SearchRequest.Builder
fields
(List<FieldAndFormat> list) Array of wildcard (*) patterns.final SearchRequest.Builder
Starting document offset.final SearchRequest.Builder
API name:highlight
final SearchRequest.Builder
API name:highlight
final SearchRequest.Builder
ignoreThrottled
(Boolean value) Whether specified concrete, expanded or aliased indices should be ignored when throttledfinal SearchRequest.Builder
ignoreUnavailable
(Boolean value) Whether specified concrete indices should be ignored when unavailable (missing or closed)final SearchRequest.Builder
A comma-separated list of index names to search; use_all
or empty string to perform the operation on all indicesfinal SearchRequest.Builder
A comma-separated list of index names to search; use_all
or empty string to perform the operation on all indicesfinal SearchRequest.Builder
indicesBoost
(List<Map<String, Double>> list) Boosts the _score of documents from specified indices.final SearchRequest.Builder
Boosts the _score of documents from specified indices.final SearchRequest.Builder
Defines the approximate kNN search to run.final SearchRequest.Builder
Defines the approximate kNN search to run.final SearchRequest.Builder
Defines the approximate kNN search to run.final SearchRequest.Builder
Specify whether format-based query failures (such as providing text to a numeric field) should be ignoredfinal SearchRequest.Builder
maxConcurrentShardRequests
(Long value) The number of concurrent shard requests per node this search executes concurrently.final SearchRequest.Builder
minCompatibleShardNode
(String value) The minimum compatible version that all shards involved in search should have for this request to be successfulfinal SearchRequest.Builder
Minimum _score for matching documents.final SearchRequest.Builder
pit
(PointInTimeReference value) Limits the search to a point in time (PIT).final SearchRequest.Builder
Limits the search to a point in time (PIT).final SearchRequest.Builder
postFilter
(Query value) API name:post_filter
final SearchRequest.Builder
API name:post_filter
final SearchRequest.Builder
preference
(String value) Specify the node or shard the operation should be performed on (default: random)final SearchRequest.Builder
preFilterShardSize
(Long value) A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold.final SearchRequest.Builder
API name:profile
final SearchRequest.Builder
Query in the Lucene query string syntaxfinal SearchRequest.Builder
Defines the search definition using the Query DSL.final SearchRequest.Builder
Defines the search definition using the Query DSL.final SearchRequest.Builder
Defines the Reciprocal Rank Fusion (RRF) to usefinal SearchRequest.Builder
Defines the Reciprocal Rank Fusion (RRF) to usefinal SearchRequest.Builder
requestCache
(Boolean value) Specify if request cache should be used for this request or not, defaults to index level settingfinal SearchRequest.Builder
API name:rescore
final SearchRequest.Builder
API name:rescore
final SearchRequest.Builder
API name:rescore
final SearchRequest.Builder
A comma-separated list of specific routing valuesfinal SearchRequest.Builder
runtimeMappings
(String key, RuntimeField value) Defines one or more runtime fields in the search request.final SearchRequest.Builder
Defines one or more runtime fields in the search request.final SearchRequest.Builder
runtimeMappings
(Map<String, RuntimeField> map) Defines one or more runtime fields in the search request.final SearchRequest.Builder
scriptFields
(String key, ScriptField value) Retrieve a script evaluation (based on different fields) for each hit.final SearchRequest.Builder
Retrieve a script evaluation (based on different fields) for each hit.final SearchRequest.Builder
scriptFields
(Map<String, ScriptField> map) Retrieve a script evaluation (based on different fields) for each hit.final SearchRequest.Builder
Specify how long a consistent view of the index should be maintained for scrolled searchfinal SearchRequest.Builder
Specify how long a consistent view of the index should be maintained for scrolled searchfinal SearchRequest.Builder
searchAfter
(FieldValue value, FieldValue... values) API name:search_after
final SearchRequest.Builder
API name:search_after
final SearchRequest.Builder
searchAfter
(List<FieldValue> list) API name:search_after
final SearchRequest.Builder
searchType
(SearchType value) Search operation typeprotected SearchRequest.Builder
self()
final SearchRequest.Builder
seqNoPrimaryTerm
(Boolean value) If true, returns sequence number and primary term of the last modification of each hit.final SearchRequest.Builder
The number of hits to return.final SearchRequest.Builder
slice
(SlicedScroll value) API name:slice
final SearchRequest.Builder
API name:slice
final SearchRequest.Builder
sort
(SortOptions value, SortOptions... values) API name:sort
final SearchRequest.Builder
API name:sort
final SearchRequest.Builder
sort
(List<SortOptions> list) API name:sort
final SearchRequest.Builder
source
(SourceConfig value) Indicates which source fields are returned for matching documents.final SearchRequest.Builder
Indicates which source fields are returned for matching documents.final SearchRequest.Builder
Stats groups to associate with the search.final SearchRequest.Builder
Stats groups to associate with the search.final SearchRequest.Builder
storedFields
(String value, String... values) List of stored fields to return as part of a hit.final SearchRequest.Builder
storedFields
(List<String> list) List of stored fields to return as part of a hit.final SearchRequest.Builder
API name:suggest
final SearchRequest.Builder
API name:suggest
final SearchRequest.Builder
terminateAfter
(Long value) Maximum number of documents to collect for each shard.final SearchRequest.Builder
Specifies the period of time to wait for a response from each shard.final SearchRequest.Builder
trackScores
(Boolean value) If true, calculate and return document scores, even if the scores are not used for sorting.final SearchRequest.Builder
trackTotalHits
(TrackHits value) Number of hits matching the query to count accurately.final SearchRequest.Builder
Number of hits matching the query to count accurately.final SearchRequest.Builder
If true, returns document version as part of a hit.Methods inherited from class co.elastic.clients.util.WithJsonObjectBuilderBase
withJson
Methods inherited from class co.elastic.clients.util.ObjectBuilderBase
_checkSingleUse, _listAdd, _listAddAll, _mapPut, _mapPutAll
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
source
Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.API name:
_source
-
source
public final SearchRequest.Builder source(Function<SourceConfig.Builder, ObjectBuilder<SourceConfig>> fn) Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.API name:
_source
-
aggregations
API name:aggregations
Adds all entries of
map
toaggregations
. -
aggregations
API name:aggregations
Adds an entry to
aggregations
. -
aggregations
public final SearchRequest.Builder aggregations(String key, Function<Aggregation.Builder, ObjectBuilder<Aggregation>> fn) API name:aggregations
Adds an entry to
aggregations
using a builder lambda. -
allowNoIndices
Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes_all
string or when no indices have been specified)API name:
allow_no_indices
-
allowPartialSearchResults
Indicate if an error should be returned if there is a partial search failure or timeoutAPI name:
allow_partial_search_results
-
analyzeWildcard
Specify whether wildcard and prefix queries should be analyzed (default: false)API name:
analyze_wildcard
-
analyzer
The analyzer to use for the query stringAPI name:
analyzer
-
batchedReduceSize
The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.API name:
batched_reduce_size
-
ccsMinimizeRoundtrips
Indicates whether network round-trips should be minimized as part of cross-cluster search requests executionAPI name:
ccs_minimize_roundtrips
-
collapse
API name:collapse
-
collapse
public final SearchRequest.Builder collapse(Function<FieldCollapse.Builder, ObjectBuilder<FieldCollapse>> fn) API name:collapse
-
defaultOperator
The default operator for query string query (AND or OR)API name:
default_operator
-
df
The field to use as default where no field prefix is given in the query stringAPI name:
df
-
docvalueFields
Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.API name:
docvalue_fields
Adds all elements of
list
todocvalueFields
. -
docvalueFields
Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.API name:
docvalue_fields
Adds one or more values to
docvalueFields
. -
docvalueFields
public final SearchRequest.Builder docvalueFields(Function<FieldAndFormat.Builder, ObjectBuilder<FieldAndFormat>> fn) Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.API name:
docvalue_fields
Adds a value to
docvalueFields
using a builder lambda. -
expandWildcards
Whether to expand wildcard expression to concrete indices that are open, closed or both.API name:
expand_wildcards
Adds all elements of
list
toexpandWildcards
. -
expandWildcards
Whether to expand wildcard expression to concrete indices that are open, closed or both.API name:
expand_wildcards
Adds one or more values to
expandWildcards
. -
explain
If true, returns detailed information about score computation as part of a hit.API name:
explain
-
ext
Configuration of search extensions defined by Elasticsearch plugins.API name:
ext
Adds all entries of
map
toext
. -
ext
Configuration of search extensions defined by Elasticsearch plugins.API name:
ext
Adds an entry to
ext
. -
fields
Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.API name:
fields
Adds all elements of
list
tofields
. -
fields
Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.API name:
fields
Adds one or more values to
fields
. -
fields
public final SearchRequest.Builder fields(Function<FieldAndFormat.Builder, ObjectBuilder<FieldAndFormat>> fn) Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.API name:
fields
Adds a value to
fields
using a builder lambda. -
from
Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.API name:
from
-
highlight
API name:highlight
-
highlight
public final SearchRequest.Builder highlight(Function<Highlight.Builder, ObjectBuilder<Highlight>> fn) API name:highlight
-
ignoreThrottled
Whether specified concrete, expanded or aliased indices should be ignored when throttledAPI name:
ignore_throttled
-
index
A comma-separated list of index names to search; use_all
or empty string to perform the operation on all indicesAPI name:
index
Adds all elements of
list
toindex
. -
index
A comma-separated list of index names to search; use_all
or empty string to perform the operation on all indicesAPI name:
index
Adds one or more values to
index
. -
indicesBoost
Boosts the _score of documents from specified indices.API name:
indices_boost
Adds all elements of
list
toindicesBoost
. -
indicesBoost
public final SearchRequest.Builder indicesBoost(Map<String, Double> value, Map<String, Double>... values) Boosts the _score of documents from specified indices.API name:
indices_boost
Adds one or more values to
indicesBoost
. -
knn
Defines the approximate kNN search to run.API name:
knn
Adds all elements of
list
toknn
. -
knn
Defines the approximate kNN search to run.API name:
knn
Adds one or more values to
knn
. -
knn
Defines the approximate kNN search to run.API name:
knn
Adds a value to
knn
using a builder lambda. -
lenient
Specify whether format-based query failures (such as providing text to a numeric field) should be ignoredAPI name:
lenient
-
maxConcurrentShardRequests
The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requestsAPI name:
max_concurrent_shard_requests
-
minCompatibleShardNode
The minimum compatible version that all shards involved in search should have for this request to be successfulAPI name:
min_compatible_shard_node
-
minScore
Minimum _score for matching documents. Documents with a lower _score are not included in the search results.API name:
min_score
-
pit
Limits the search to a point in time (PIT). If you provide a PIT, you cannot specify an <index> in the request path.API name:
pit
-
pit
public final SearchRequest.Builder pit(Function<PointInTimeReference.Builder, ObjectBuilder<PointInTimeReference>> fn) Limits the search to a point in time (PIT). If you provide a PIT, you cannot specify an <index> in the request path.API name:
pit
-
postFilter
API name:post_filter
-
postFilter
API name:post_filter
-
preFilterShardSize
A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.API name:
pre_filter_shard_size
-
preference
Specify the node or shard the operation should be performed on (default: random)API name:
preference
-
profile
API name:profile
-
q
Query in the Lucene query string syntaxAPI name:
q
-
query
Defines the search definition using the Query DSL.API name:
query
-
query
Defines the search definition using the Query DSL.API name:
query
-
rank
Defines the Reciprocal Rank Fusion (RRF) to useAPI name:
rank
-
rank
Defines the Reciprocal Rank Fusion (RRF) to useAPI name:
rank
-
requestCache
Specify if request cache should be used for this request or not, defaults to index level settingAPI name:
request_cache
-
rescore
API name:rescore
Adds all elements of
list
torescore
. -
rescore
API name:rescore
Adds one or more values to
rescore
. -
rescore
API name:rescore
Adds a value to
rescore
using a builder lambda. -
routing
A comma-separated list of specific routing valuesAPI name:
routing
-
runtimeMappings
Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.API name:
runtime_mappings
Adds all entries of
map
toruntimeMappings
. -
runtimeMappings
Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.API name:
runtime_mappings
Adds an entry to
runtimeMappings
. -
runtimeMappings
public final SearchRequest.Builder runtimeMappings(String key, Function<RuntimeField.Builder, ObjectBuilder<RuntimeField>> fn) Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.API name:
runtime_mappings
Adds an entry to
runtimeMappings
using a builder lambda. -
scriptFields
Retrieve a script evaluation (based on different fields) for each hit.API name:
script_fields
Adds all entries of
map
toscriptFields
. -
scriptFields
Retrieve a script evaluation (based on different fields) for each hit.API name:
script_fields
Adds an entry to
scriptFields
. -
scriptFields
public final SearchRequest.Builder scriptFields(String key, Function<ScriptField.Builder, ObjectBuilder<ScriptField>> fn) Retrieve a script evaluation (based on different fields) for each hit.API name:
script_fields
Adds an entry to
scriptFields
using a builder lambda. -
scroll
Specify how long a consistent view of the index should be maintained for scrolled searchAPI name:
scroll
-
scroll
Specify how long a consistent view of the index should be maintained for scrolled searchAPI name:
scroll
-
searchAfter
API name:search_after
Adds all elements of
list
tosearchAfter
. -
searchAfter
API name:search_after
Adds one or more values to
searchAfter
. -
searchAfter
public final SearchRequest.Builder searchAfter(Function<FieldValue.Builder, ObjectBuilder<FieldValue>> fn) API name:search_after
Adds a value to
searchAfter
using a builder lambda. -
searchType
Search operation typeAPI name:
search_type
-
seqNoPrimaryTerm
If true, returns sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.API name:
seq_no_primary_term
-
size
The number of hits to return. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.API name:
size
-
slice
API name:slice
-
slice
public final SearchRequest.Builder slice(Function<SlicedScroll.Builder, ObjectBuilder<SlicedScroll>> fn) API name:slice
-
sort
API name:sort
Adds all elements of
list
tosort
. -
sort
API name:sort
Adds one or more values to
sort
. -
sort
public final SearchRequest.Builder sort(Function<SortOptions.Builder, ObjectBuilder<SortOptions>> fn) API name:sort
Adds a value to
sort
using a builder lambda. -
stats
Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.API name:
stats
Adds all elements of
list
tostats
. -
stats
Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.API name:
stats
Adds one or more values to
stats
. -
storedFields
List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response.API name:
stored_fields
Adds all elements of
list
tostoredFields
. -
storedFields
List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response.API name:
stored_fields
Adds one or more values to
storedFields
. -
suggest
API name:suggest
-
suggest
API name:suggest
-
terminateAfter
Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Defaults to 0, which does not terminate query execution early.API name:
terminate_after
-
timeout
Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.API name:
timeout
-
trackScores
If true, calculate and return document scores, even if the scores are not used for sorting.API name:
track_scores
-
trackTotalHits
Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.API name:
track_total_hits
-
trackTotalHits
public final SearchRequest.Builder trackTotalHits(Function<TrackHits.Builder, ObjectBuilder<TrackHits>> fn) Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.API name:
track_total_hits
-
version
If true, returns document version as part of a hit.API name:
version
-
self
- Specified by:
self
in classRequestBase.AbstractBuilder<SearchRequest.Builder>
-
build
Builds aSearchRequest
.- Specified by:
build
in interfaceObjectBuilder<SearchRequest>
- Throws:
NullPointerException
- if some of the required fields are null.
-