Class SearchRequest

java.lang.Object
co.elastic.clients.elasticsearch._types.RequestBase
co.elastic.clients.elasticsearch._core.SearchRequest
All Implemented Interfaces:
ElasticsearchCommonRequest, JsonpSerializable

@JsonpDeserializable
public final class SearchRequest
extends RequestBase
implements JsonpSerializable
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  SearchRequest.Builder
    Builder for SearchRequest.

    Nested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBase

    RequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
  • Field Summary

    Fields
    Modifier and Type Field Description
    static JsonpDeserializer<SearchRequest> _DESERIALIZER
    Json deserializer for SearchRequest
  • Constructor Summary

    Constructors
    Constructor Description
    SearchRequest​(SearchRequest.Builder builder)  
    SearchRequest​(java.util.function.Function<SearchRequest.Builder,​SearchRequest.Builder> fn)  
  • Method Summary

    Modifier and Type Method Description
    java.util.Map<java.lang.String,​Aggregation> aggregations()
    API name: aggregations
    java.util.Map<java.lang.String,​Aggregation> aggs()
    API name: aggs
    java.lang.Boolean allowNoIndices()
    Whether to ignore if a wildcard indices expression resolves into no concrete indices.
    java.lang.Boolean allowPartialSearchResults()
    Indicate if an error should be returned if there is a partial search failure or timeout
    java.lang.String analyzer()
    The analyzer to use for the query string
    java.lang.Boolean analyzeWildcard()
    Specify whether wildcard and prefix queries should be analyzed (default: false)
    java.lang.Long batchedReduceSize()
    The number of shard results that should be reduced at once on the coordinating node.
    java.lang.Boolean ccsMinimizeRoundtrips()
    Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
    FieldCollapse collapse()
    API name: collapse
    static <TDocument>
    Endpoint<SearchRequest,​SearchResponse<TDocument>,​ElasticsearchError>
    createSearchEndpoint​(JsonpDeserializer<TDocument> tDocumentDeserializer)
    Create an "search" endpoint.
    DefaultOperator defaultOperator()
    The default operator for query string query (AND or OR)
    java.lang.String df()
    The field to use as default where no field prefix is given in the query string
    jakarta.json.JsonValue docvalueFields()
    Array of wildcard (*) patterns.
    java.util.List<ExpandWildcardOptions> expandWildcards()
    Whether to expand wildcard expression to concrete indices that are open, closed or both.
    java.lang.Boolean explain()
    If true, returns detailed information about score computation as part of a hit.
    java.util.List<jakarta.json.JsonValue> fields()
    Array of wildcard (*) patterns.
    java.lang.Integer from()
    Starting document offset.
    Highlight highlight()
    API name: highlight
    java.lang.Boolean ignoreThrottled()
    Whether specified concrete, expanded or aliased indices should be ignored when throttled
    java.lang.Boolean ignoreUnavailable()
    Whether specified concrete indices should be ignored when unavailable (missing or closed)
    java.util.List<java.lang.String> index()
    A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
    java.util.List<java.util.Map<java.lang.String,​java.lang.Double>> indicesBoost()
    Boosts the _score of documents from specified indices.
    java.lang.Boolean lenient()
    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
    java.lang.Long maxConcurrentShardRequests()
    The number of concurrent shard requests per node this search executes concurrently.
    java.lang.String minCompatibleShardNode()
    The minimum compatible version that all shards involved in search should have for this request to be successful
    java.lang.Double minScore()
    Minimum _score for matching documents.
    PointInTimeReference pit()
    Limits the search to a point in time (PIT).
    Query postFilter()
    API name: post_filter
    java.lang.String preference()
    Specify the node or shard the operation should be performed on (default: random)
    java.lang.Long 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.
    java.lang.Boolean profile()
    API name: profile
    java.lang.String q()
    Query in the Lucene query string syntax
    Query query()
    Defines the search definition using the Query DSL.
    java.lang.Boolean requestCache()
    Specify if request cache should be used for this request or not, defaults to index level setting
    java.util.List<Rescore> rescore()
    API name: rescore
    java.lang.String routing()
    A comma-separated list of specific routing values
    java.util.Map<java.lang.String,​RuntimeField> runtimeMappings()
    Defines one or more runtime fields in the search request.
    java.util.Map<java.lang.String,​ScriptField> scriptFields()
    Retrieve a script evaluation (based on different fields) for each hit.
    java.lang.String scroll()
    Specify how long a consistent view of the index should be maintained for scrolled search
    java.util.List<java.lang.String> searchAfter()
    API name: search_after
    SearchType searchType()
    Search operation type
    java.lang.Boolean seqNoPrimaryTerm()
    If true, returns sequence number and primary term of the last modification of each hit.
    void serialize​(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
    Serialize this object to JSON.
    protected void serializeInternal​(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)  
    protected static void setupSearchRequestDeserializer​(DelegatingDeserializer<SearchRequest.Builder> op)  
    java.lang.Integer size()
    The number of hits to return.
    SlicedScroll slice()
    API name: slice
    java.util.List<jakarta.json.JsonValue> sort()
    API name: sort
    jakarta.json.JsonValue source()
    Indicates which source fields are returned for matching documents.
    java.util.List<java.lang.String> sourceExcludes()
    A list of fields to exclude from the returned _source field
    java.util.List<java.lang.String> sourceIncludes()
    A list of fields to extract and return from the _source field
    java.util.List<java.lang.String> stats()
    Stats groups to associate with the search.
    java.util.List<java.lang.String> storedFields()
    List of stored fields to return as part of a hit.
    jakarta.json.JsonValue suggest()
    API name: suggest
    java.lang.String suggestField()
    Specifies which field to use for suggestions.
    SuggestMode suggestMode()
    Specify suggest mode
    java.lang.Long suggestSize()
    How many suggestions to return in response
    java.lang.String suggestText()
    The source text for which the suggestions should be returned.
    java.lang.Long terminateAfter()
    Maximum number of documents to collect for each shard.
    java.lang.String timeout()
    Specifies the period of time to wait for a response from each shard.
    java.lang.Boolean trackScores()
    If true, calculate and return document scores, even if the scores are not used for sorting.
    jakarta.json.JsonValue trackTotalHits()
    Number of hits matching the query to count accurately.
    java.util.List<java.lang.String> type()
    A comma-separated list of document types to search; leave empty to perform the operation on all types
    java.lang.Boolean typedKeys()
    Specify whether aggregation and suggester names should be prefixed by their respective types in the response
    java.lang.Boolean version()
    If true, returns document version as part of a hit.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • index

      @Nullable public java.util.List<java.lang.String> index()
      A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices

      API name: index

    • type

      @Nullable public java.util.List<java.lang.String> type()
      A comma-separated list of document types to search; leave empty to perform the operation on all types

      API name: type

    • allowNoIndices

      @Nullable public java.lang.Boolean 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

      @Nullable public java.lang.Boolean allowPartialSearchResults()
      Indicate if an error should be returned if there is a partial search failure or timeout

      API name: allow_partial_search_results

    • analyzer

      @Nullable public java.lang.String analyzer()
      The analyzer to use for the query string

      API name: analyzer

    • analyzeWildcard

      @Nullable public java.lang.Boolean analyzeWildcard()
      Specify whether wildcard and prefix queries should be analyzed (default: false)

      API name: analyze_wildcard

    • batchedReduceSize

      @Nullable public java.lang.Long 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

      @Nullable public java.lang.Boolean ccsMinimizeRoundtrips()
      Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution

      API name: ccs_minimize_roundtrips

    • defaultOperator

      @Nullable public DefaultOperator defaultOperator()
      The default operator for query string query (AND or OR)

      API name: default_operator

    • df

      @Nullable public java.lang.String df()
      The field to use as default where no field prefix is given in the query string

      API name: df

    • expandWildcards

      @Nullable public java.util.List<ExpandWildcardOptions> expandWildcards()
      Whether to expand wildcard expression to concrete indices that are open, closed or both.

      API name: expand_wildcards

    • ignoreThrottled

      @Nullable public java.lang.Boolean ignoreThrottled()
      Whether specified concrete, expanded or aliased indices should be ignored when throttled

      API name: ignore_throttled

    • ignoreUnavailable

      @Nullable public java.lang.Boolean ignoreUnavailable()
      Whether specified concrete indices should be ignored when unavailable (missing or closed)

      API name: ignore_unavailable

    • lenient

      @Nullable public java.lang.Boolean lenient()
      Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

      API name: lenient

    • maxConcurrentShardRequests

      @Nullable public java.lang.Long 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 requests

      API name: max_concurrent_shard_requests

    • minCompatibleShardNode

      @Nullable public java.lang.String minCompatibleShardNode()
      The minimum compatible version that all shards involved in search should have for this request to be successful

      API name: min_compatible_shard_node

    • preference

      @Nullable public java.lang.String preference()
      Specify the node or shard the operation should be performed on (default: random)

      API name: preference

    • preFilterShardSize

      @Nullable public java.lang.Long 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

    • requestCache

      @Nullable public java.lang.Boolean requestCache()
      Specify if request cache should be used for this request or not, defaults to index level setting

      API name: request_cache

    • routing

      @Nullable public java.lang.String routing()
      A comma-separated list of specific routing values

      API name: routing

    • scroll

      @Nullable public java.lang.String scroll()
      Specify how long a consistent view of the index should be maintained for scrolled search

      API name: scroll

    • searchType

      @Nullable public SearchType searchType()
      Search operation type

      API name: search_type

    • suggestField

      @Nullable public java.lang.String suggestField()
      Specifies which field to use for suggestions.

      API name: suggest_field

    • suggestMode

      @Nullable public SuggestMode suggestMode()
      Specify suggest mode

      API name: suggest_mode

    • suggestSize

      @Nullable public java.lang.Long suggestSize()
      How many suggestions to return in response

      API name: suggest_size

    • suggestText

      @Nullable public java.lang.String suggestText()
      The source text for which the suggestions should be returned.

      API name: suggest_text

    • typedKeys

      @Nullable public java.lang.Boolean typedKeys()
      Specify whether aggregation and suggester names should be prefixed by their respective types in the response

      API name: typed_keys

    • sourceExcludes

      @Nullable public java.util.List<java.lang.String> sourceExcludes()
      A list of fields to exclude from the returned _source field

      API name: _source_excludes

    • sourceIncludes

      @Nullable public java.util.List<java.lang.String> sourceIncludes()
      A list of fields to extract and return from the _source field

      API name: _source_includes

    • q

      @Nullable public java.lang.String q()
      Query in the Lucene query string syntax

      API name: q

    • aggs

      @Nullable public java.util.Map<java.lang.String,​Aggregation> aggs()
      API name: aggs
    • aggregations

      @Nullable public java.util.Map<java.lang.String,​Aggregation> aggregations()
      API name: aggregations
    • collapse

      @Nullable public FieldCollapse collapse()
      API name: collapse
    • explain

      @Nullable public java.lang.Boolean explain()
      If true, returns detailed information about score computation as part of a hit.

      API name: explain

    • from

      @Nullable public java.lang.Integer 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

      @Nullable public Highlight highlight()
      API name: highlight
    • trackTotalHits

      @Nullable public jakarta.json.JsonValue 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

    • indicesBoost

      @Nullable public java.util.List<java.util.Map<java.lang.String,​java.lang.Double>> indicesBoost()
      Boosts the _score of documents from specified indices.

      API name: indices_boost

    • docvalueFields

      @Nullable public jakarta.json.JsonValue 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

    • minScore

      @Nullable public java.lang.Double minScore()
      Minimum _score for matching documents. Documents with a lower _score are not included in the search results.

      API name: min_score

    • postFilter

      @Nullable public Query postFilter()
      API name: post_filter
    • profile

      @Nullable public java.lang.Boolean profile()
      API name: profile
    • query

      @Nullable public Query query()
      Defines the search definition using the Query DSL.

      API name: query

    • rescore

      @Nullable public java.util.List<Rescore> rescore()
      API name: rescore
    • scriptFields

      @Nullable public java.util.Map<java.lang.String,​ScriptField> scriptFields()
      Retrieve a script evaluation (based on different fields) for each hit.

      API name: script_fields

    • searchAfter

      @Nullable public java.util.List<java.lang.String> searchAfter()
      API name: search_after
    • size

      @Nullable public java.lang.Integer 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

      @Nullable public SlicedScroll slice()
      API name: slice
    • sort

      @Nullable public java.util.List<jakarta.json.JsonValue> sort()
      API name: sort
    • source

      @Nullable public jakarta.json.JsonValue 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

    • fields

      @Nullable public java.util.List<jakarta.json.JsonValue> 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

    • suggest

      @Nullable public jakarta.json.JsonValue suggest()
      API name: suggest
    • terminateAfter

      @Nullable public java.lang.Long 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

      @Nullable public java.lang.String 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

      @Nullable public java.lang.Boolean trackScores()
      If true, calculate and return document scores, even if the scores are not used for sorting.

      API name: track_scores

    • version

      @Nullable public java.lang.Boolean version()
      If true, returns document version as part of a hit.

      API name: version

    • seqNoPrimaryTerm

      @Nullable public java.lang.Boolean 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

    • storedFields

      @Nullable public java.util.List<java.lang.String> 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

    • pit

      @Nullable public PointInTimeReference 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

    • runtimeMappings

      @Nullable public java.util.Map<java.lang.String,​RuntimeField> 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

    • stats

      @Nullable public java.util.List<java.lang.String> 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

    • serialize

      public void serialize​(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
      Serialize this object to JSON.
      Specified by:
      serialize in interface JsonpSerializable
    • serializeInternal

      protected void serializeInternal​(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
    • setupSearchRequestDeserializer

      protected static void setupSearchRequestDeserializer​(DelegatingDeserializer<SearchRequest.Builder> op)
    • createSearchEndpoint

      public static <TDocument> Endpoint<SearchRequest,​SearchResponse<TDocument>,​ElasticsearchError> createSearchEndpoint​(JsonpDeserializer<TDocument> tDocumentDeserializer)
      Create an "search" endpoint.