Class SearchRequestBody.Builder
- All Implemented Interfaces:
WithJson<SearchRequestBody.Builder>
,ObjectBuilder<SearchRequestBody>
- Enclosing class:
- SearchRequestBody
SearchRequestBody
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaggregations
(String key, Aggregation value) Defines the aggregations that are run as part of the search request.aggregations
(String key, AggregationVariant value) Defines the aggregations that are run as part of the search request.Defines the aggregations that are run as part of the search request.aggregations
(Map<String, Aggregation> map) Defines the aggregations that are run as part of the search request.build()
Builds aSearchRequestBody
.collapse
(FieldCollapse value) Collapses search results the values of the specified field.Collapses search results the values of the specified field.docvalueFields
(FieldAndFormat value, FieldAndFormat... values) An array of wildcard (*
) field patterns.An array of wildcard (*
) field patterns.docvalueFields
(List<FieldAndFormat> list) An array of wildcard (*
) field patterns.Iftrue
, the request returns detailed information about score computation as part of a hit.Configuration of search extensions defined by Elasticsearch plugins.Configuration of search extensions defined by Elasticsearch plugins.fields
(FieldAndFormat value, FieldAndFormat... values) An array of wildcard (*
) field patterns.An array of wildcard (*
) field patterns.fields
(List<FieldAndFormat> list) An array of wildcard (*
) field patterns.The starting document offset, which must be non-negative.Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.indicesBoost
(NamedValue<Double> value, NamedValue<Double>... values) Boost the_score
of documents from specified indices.indicesBoost
(List<NamedValue<Double>> list) Boost the_score
of documents from specified indices.The approximate kNN search to run.The approximate kNN search to run.The approximate kNN search to run.The minimum_score
for matching documents.pit
(PointInTimeReference value) Limit the search to a point in time (PIT).Limit the search to a point in time (PIT).postFilter
(Query value) Use thepost_filter
parameter to filter search results.postFilter
(QueryVariant value) Use thepost_filter
parameter to filter search results.Use thepost_filter
parameter to filter search results.Set totrue
to return detailed timing information about the execution of individual components in a search request.The search definition using the Query DSL.query
(QueryVariant value) The search definition using the Query DSL.The search definition using the Query DSL.The Reciprocal Rank Fusion (RRF) to use.rank
(RankVariant value) The Reciprocal Rank Fusion (RRF) to use.The Reciprocal Rank Fusion (RRF) to use.Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.rescore
(RescoreVariant value, RescoreVariant... values) Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.A retriever is a specification to describe top documents returned from a search.retriever
(RetrieverVariant value) A retriever is a specification to describe top documents returned from a search.A retriever is a specification to describe top documents returned from a search.runtimeMappings
(String key, RuntimeField value) One or more runtime fields in the search request.One or more runtime fields in the search request.runtimeMappings
(Map<String, RuntimeField> map) One or more runtime fields in the search request.scriptFields
(String key, ScriptField value) Retrieve a script evaluation (based on different fields) for each hit.Retrieve a script evaluation (based on different fields) for each hit.scriptFields
(Map<String, ScriptField> map) Retrieve a script evaluation (based on different fields) for each hit.searchAfter
(boolean value, boolean... values) Used to retrieve the next page of hits using a set of sort values from the previous page.searchAfter
(double value, double... values) Used to retrieve the next page of hits using a set of sort values from the previous page.searchAfter
(long value, long... values) Used to retrieve the next page of hits using a set of sort values from the previous page.searchAfter
(FieldValue value, FieldValue... values) Used to retrieve the next page of hits using a set of sort values from the previous page.searchAfter
(String value, String... values) Used to retrieve the next page of hits using a set of sort values from the previous page.Used to retrieve the next page of hits using a set of sort values from the previous page.searchAfter
(List<FieldValue> list) Used to retrieve the next page of hits using a set of sort values from the previous page.protected SearchRequestBody.Builder
self()
seqNoPrimaryTerm
(Boolean value) Iftrue
, the request returns sequence number and primary term of the last modification of each hit.The number of hits to return, which must not be negative.slice
(SlicedScroll value) Split a scrolled search into multiple slices that can be consumed independently.Split a scrolled search into multiple slices that can be consumed independently.sort
(SortOptions value, SortOptions... values) A comma-separated list of <field>:<direction> pairs.A comma-separated list of <field>:<direction> pairs.sort
(List<SortOptions> list) A comma-separated list of <field>:<direction> pairs.source
(SourceConfig value) The source fields that are returned for matching documents.The source fields that are returned for matching documents.The stats groups to associate with the search.The stats groups to associate with the search.storedFields
(String value, String... values) A comma-separated list of stored fields to return as part of a hit.storedFields
(List<String> list) A comma-separated list of stored fields to return as part of a hit.Defines a suggester that provides similar looking terms based on a provided text.Defines a suggester that provides similar looking terms based on a provided text.terminateAfter
(Long value) The maximum number of documents to collect for each shard.The period of time to wait for a response from each shard.trackScores
(Boolean value) Iftrue
, calculate and return document scores, even if the scores are not used for sorting.trackTotalHits
(TrackHits value) Number of hits matching the query to count accurately.Number of hits matching the query to count accurately.Iftrue
, the request returns the 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
-
aggregations
Defines the aggregations that are run as part of the search request.API name:
aggregations
Adds all entries of
map
toaggregations
. -
aggregations
Defines the aggregations that are run as part of the search request.API name:
aggregations
Adds an entry to
aggregations
. -
aggregations
Defines the aggregations that are run as part of the search request.API name:
aggregations
Adds an entry to
aggregations
. -
aggregations
public final SearchRequestBody.Builder aggregations(String key, Function<Aggregation.Builder, ObjectBuilder<Aggregation>> fn) Defines the aggregations that are run as part of the search request.API name:
aggregations
Adds an entry to
aggregations
using a builder lambda. -
collapse
Collapses search results the values of the specified field.API name:
collapse
-
collapse
public final SearchRequestBody.Builder collapse(Function<FieldCollapse.Builder, ObjectBuilder<FieldCollapse>> fn) Collapses search results the values of the specified field.API name:
collapse
-
explain
Iftrue
, the request 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
. -
from
The starting document offset, which must be non-negative. By default, you cannot page through more than 10,000 hits using thefrom
andsize
parameters. To page through more hits, use thesearch_after
parameter.API name:
from
-
highlight
Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.API name:
highlight
-
highlight
public final SearchRequestBody.Builder highlight(Function<Highlight.Builder, ObjectBuilder<Highlight>> fn) Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.API name:
highlight
-
trackTotalHits
Number of hits matching the query to count accurately. Iftrue
, the exact number of hits is returned at the cost of some performance. Iffalse
, the response does not include the total number of hits matching the query.API name:
track_total_hits
-
trackTotalHits
public final SearchRequestBody.Builder trackTotalHits(Function<TrackHits.Builder, ObjectBuilder<TrackHits>> fn) Number of hits matching the query to count accurately. Iftrue
, the exact number of hits is returned at the cost of some performance. Iffalse
, the response does not include the total number of hits matching the query.API name:
track_total_hits
-
indicesBoost
Boost the_score
of documents from specified indices. The boost value is the factor by which scores are multiplied. A boost value greater than1.0
increases the score. A boost value between0
and1.0
decreases the score.API name:
indices_boost
Adds all elements of
list
toindicesBoost
. -
indicesBoost
@SafeVarargs public final SearchRequestBody.Builder indicesBoost(NamedValue<Double> value, NamedValue<Double>... values) Boost the_score
of documents from specified indices. The boost value is the factor by which scores are multiplied. A boost value greater than1.0
increases the score. A boost value between0
and1.0
decreases the score.API name:
indices_boost
Adds one or more values to
indicesBoost
. -
docvalueFields
An array of wildcard (*
) field patterns. The request returns doc values for field names matching these patterns in thehits.fields
property of the response.API name:
docvalue_fields
Adds all elements of
list
todocvalueFields
. -
docvalueFields
public final SearchRequestBody.Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) An array of wildcard (*
) field patterns. The request returns doc values for field names matching these patterns in thehits.fields
property of the response.API name:
docvalue_fields
Adds one or more values to
docvalueFields
. -
docvalueFields
public final SearchRequestBody.Builder docvalueFields(Function<FieldAndFormat.Builder, ObjectBuilder<FieldAndFormat>> fn) An array of wildcard (*
) field patterns. The request returns doc values for field names matching these patterns in thehits.fields
property of the response.API name:
docvalue_fields
Adds a value to
docvalueFields
using a builder lambda. -
knn
The approximate kNN search to run.API name:
knn
Adds all elements of
list
toknn
. -
knn
The approximate kNN search to run.API name:
knn
Adds one or more values to
knn
. -
knn
The approximate kNN search to run.API name:
knn
Adds a value to
knn
using a builder lambda. -
rank
The Reciprocal Rank Fusion (RRF) to use.API name:
rank
-
rank
The Reciprocal Rank Fusion (RRF) to use.API name:
rank
-
rank
The Reciprocal Rank Fusion (RRF) to use.API name:
rank
-
minScore
The minimum_score
for matching documents. Documents with a lower_score
are not included in search results or results collected by aggregations.API name:
min_score
-
postFilter
Use thepost_filter
parameter to filter search results. The search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results.API name:
post_filter
-
postFilter
Use thepost_filter
parameter to filter search results. The search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results.API name:
post_filter
-
postFilter
Use thepost_filter
parameter to filter search results. The search hits are filtered after the aggregations are calculated. A post filter has no impact on the aggregation results.API name:
post_filter
-
profile
Set totrue
to return detailed timing information about the execution of individual components in a search request. NOTE: This is a debugging tool and adds significant overhead to search execution.API name:
profile
-
query
The search definition using the Query DSL.API name:
query
-
query
The search definition using the Query DSL.API name:
query
-
query
The search definition using the Query DSL.API name:
query
-
rescore
Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.API name:
rescore
Adds all elements of
list
torescore
. -
rescore
Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.API name:
rescore
Adds one or more values to
rescore
. -
rescore
Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.API name:
rescore
Adds one or more values to
rescore
. -
rescore
Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by thequery
andpost_filter
phases.API name:
rescore
Adds a value to
rescore
using a builder lambda. -
retriever
A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such asquery
andknn
.API name:
retriever
-
retriever
public final SearchRequestBody.Builder retriever(Function<Retriever.Builder, ObjectBuilder<Retriever>> fn) A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such asquery
andknn
.API name:
retriever
-
retriever
A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such asquery
andknn
.API name:
retriever
-
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 SearchRequestBody.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. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds all elements of
list
tosearchAfter
. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds one or more values to
searchAfter
. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds one or more values to
searchAfter
. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds one or more values to
searchAfter
. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds one or more values to
searchAfter
. -
searchAfter
Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds one or more values to
searchAfter
. -
searchAfter
public final SearchRequestBody.Builder searchAfter(Function<FieldValue.Builder, ObjectBuilder<FieldValue>> fn) Used to retrieve the next page of hits using a set of sort values from the previous page.API name:
search_after
Adds a value to
searchAfter
using a builder lambda. -
size
The number of hits to return, which must not be negative. By default, you cannot page through more than 10,000 hits using thefrom
andsize
parameters. To page through more hits, use thesearch_after
property.API name:
size
-
slice
Split a scrolled search into multiple slices that can be consumed independently.API name:
slice
-
slice
public final SearchRequestBody.Builder slice(Function<SlicedScroll.Builder, ObjectBuilder<SlicedScroll>> fn) Split a scrolled search into multiple slices that can be consumed independently.API name:
slice
-
sort
A comma-separated list of <field>:<direction> pairs.API name:
sort
Adds all elements of
list
tosort
. -
sort
A comma-separated list of <field>:<direction> pairs.API name:
sort
Adds one or more values to
sort
. -
sort
public final SearchRequestBody.Builder sort(Function<SortOptions.Builder, ObjectBuilder<SortOptions>> fn) A comma-separated list of <field>:<direction> pairs.API name:
sort
Adds a value to
sort
using a builder lambda. -
source
The source fields that are returned for matching documents. These fields are returned in thehits._source
property of the search response. If thestored_fields
property is specified, the_source
property defaults tofalse
. Otherwise, it defaults totrue
.API name:
_source
-
source
public final SearchRequestBody.Builder source(Function<SourceConfig.Builder, ObjectBuilder<SourceConfig>> fn) The source fields that are returned for matching documents. These fields are returned in thehits._source
property of the search response. If thestored_fields
property is specified, the_source
property defaults tofalse
. Otherwise, it defaults totrue
.API name:
_source
-
fields
An array of wildcard (*
) field patterns. The request returns values for field names matching these patterns in thehits.fields
property of the response.API name:
fields
Adds all elements of
list
tofields
. -
fields
An array of wildcard (*
) field patterns. The request returns values for field names matching these patterns in thehits.fields
property of the response.API name:
fields
Adds one or more values to
fields
. -
fields
public final SearchRequestBody.Builder fields(Function<FieldAndFormat.Builder, ObjectBuilder<FieldAndFormat>> fn) An array of wildcard (*
) field patterns. The request returns values for field names matching these patterns in thehits.fields
property of the response.API name:
fields
Adds a value to
fields
using a builder lambda. -
suggest
Defines a suggester that provides similar looking terms based on a provided text.API name:
suggest
-
suggest
public final SearchRequestBody.Builder suggest(Function<Suggester.Builder, ObjectBuilder<Suggester>> fn) Defines a suggester that provides similar looking terms based on a provided text.API name:
suggest
-
terminateAfter
The 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.IMPORTANT: Use with caution. Elasticsearch applies this property to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this property for requests that target data streams with backing indices across multiple data tiers.
If set to
0
(default), the query does not terminate early.API name:
terminate_after
-
timeout
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
Iftrue
, calculate and return document scores, even if the scores are not used for sorting.API name:
track_scores
-
version
Iftrue
, the request returns the document version as part of a hit.API name:
version
-
seqNoPrimaryTerm
Iftrue
, the request returns sequence number and primary term of the last modification of each hit.API name:
seq_no_primary_term
-
storedFields
A comma-separated 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
property defaults tofalse
. 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
A comma-separated 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
property defaults tofalse
. 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
. -
pit
Limit 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 SearchRequestBody.Builder pit(Function<PointInTimeReference.Builder, ObjectBuilder<PointInTimeReference>> fn) Limit 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
-
runtimeMappings
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
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 SearchRequestBody.Builder runtimeMappings(String key, Function<RuntimeField.Builder, ObjectBuilder<RuntimeField>> fn) 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. -
stats
The 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
The 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
. -
self
- Specified by:
self
in classWithJsonObjectBuilderBase<SearchRequestBody.Builder>
-
build
Builds aSearchRequestBody
.- Specified by:
build
in interfaceObjectBuilder<SearchRequestBody>
- Throws:
NullPointerException
- if some of the required fields are null.
-