Class SearchRequestBody

java.lang.Object
co.elastic.clients.elasticsearch.core.search.SearchRequestBody
All Implemented Interfaces:
JsonpSerializable

@JsonpDeserializable public class SearchRequestBody extends Object implements JsonpSerializable
See Also:
  • Field Details

  • Method Details

    • of

    • aggregations

      public final Map<String,Aggregation> aggregations()
      Defines the aggregations that are run as part of the search request.

      API name: aggregations

    • collapse

      @Nullable public final FieldCollapse collapse()
      Collapses search results the values of the specified field.

      API name: collapse

    • explain

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

      API name: explain

    • ext

      public final Map<String,JsonData> ext()
      Configuration of search extensions defined by Elasticsearch plugins.

      API name: ext

    • from

      @Nullable public final Integer from()
      The starting document offset, which must be non-negative. 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 final Highlight highlight()
      Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.

      API name: highlight

    • trackTotalHits

      @Nullable public final TrackHits 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.

      API name: track_total_hits

    • indicesBoost

      public final List<NamedValue<Double>> indicesBoost()
      Boost the _score of documents from specified indices. The boost value is the factor by which scores are multiplied. A boost value greater than 1.0 increases the score. A boost value between 0 and 1.0 decreases the score.

      API name: indices_boost

    • docvalueFields

      public final List<FieldAndFormat> docvalueFields()
      An array of wildcard (*) field patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.

      API name: docvalue_fields

    • knn

      public final List<KnnSearch> knn()
      The approximate kNN search to run.

      API name: knn

    • rank

      @Nullable public final Rank rank()
      The Reciprocal Rank Fusion (RRF) to use.

      API name: rank

    • minScore

      @Nullable public final Double 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

      @Nullable public final Query postFilter()
      Use the post_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

      @Nullable public final Boolean profile()
      Set to true 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

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

      API name: query

    • rescore

      public final List<Rescore> rescore()
      Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the query and post_filter phases.

      API name: rescore

    • retriever

      @Nullable public final 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 as query and knn.

      API name: retriever

    • scriptFields

      public final Map<String,ScriptField> scriptFields()
      Retrieve a script evaluation (based on different fields) for each hit.

      API name: script_fields

    • searchAfter

      public final List<FieldValue> searchAfter()
      Used to retrieve the next page of hits using a set of sort values from the previous page.

      API name: search_after

    • size

      @Nullable public final Integer size()
      The number of hits to return, which must not be negative. 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 property.

      API name: size

    • slice

      @Nullable public final SlicedScroll slice()
      Split a scrolled search into multiple slices that can be consumed independently.

      API name: slice

    • sort

      public final List<SortOptions> sort()
      A comma-separated list of <field>:<direction> pairs.

      API name: sort

    • source

      @Nullable public final SourceConfig source()
      The source fields that are returned for matching documents. These fields are returned in the hits._source property of the search response. If the stored_fields property is specified, the _source property defaults to false. Otherwise, it defaults to true.

      API name: _source

    • fields

      public final List<FieldAndFormat> fields()
      An array of wildcard (*) field 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 final Suggester suggest()
      Defines a suggester that provides similar looking terms based on a provided text.

      API name: suggest

    • terminateAfter

      @Nullable public final Long 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

      @Nullable public final String 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

      @Nullable public final 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 final Boolean version()
      If true, the request returns the document version as part of a hit.

      API name: version

    • seqNoPrimaryTerm

      @Nullable public final Boolean seqNoPrimaryTerm()
      If true, the request returns sequence number and primary term of the last modification of each hit.

      API name: seq_no_primary_term

    • storedFields

      public final List<String> 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 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 final PointInTimeReference 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

    • runtimeMappings

      public final Map<String,RuntimeField> 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

    • stats

      public final List<String> 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

    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setupSearchRequestBodyDeserializer

      protected static void setupSearchRequestBodyDeserializer(ObjectDeserializer<SearchRequestBody.Builder> op)