Class MsearchRequest.Builder

All Implemented Interfaces:
WithJson<MsearchRequest.Builder>, ObjectBuilder<MsearchRequest>
Enclosing class:
MsearchRequest

public static class MsearchRequest.Builder extends RequestBase.AbstractBuilder<MsearchRequest.Builder> implements ObjectBuilder<MsearchRequest>
Builder for MsearchRequest.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • allowNoIndices

      public final MsearchRequest.Builder allowNoIndices(@Nullable Boolean value)
      A setting that does two separate checks on the index expression. If false, the request returns an error (1) if any wildcard expression (including _all and *) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If true, index expressions that resolve to no indices are allowed and the request returns an empty result.

      API name: allow_no_indices

    • ccsMinimizeRoundtrips

      public final MsearchRequest.Builder ccsMinimizeRoundtrips(@Nullable Boolean value)
      If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests.

      API name: ccs_minimize_roundtrips

    • expandWildcards

      public final MsearchRequest.Builder expandWildcards(List<ExpandWildcard> list)
      Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.

      API name: expand_wildcards

      Adds all elements of list to expandWildcards.

    • expandWildcards

      public final MsearchRequest.Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values)
      Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.

      API name: expand_wildcards

      Adds one or more values to expandWildcards.

    • ignoreThrottled

      @Deprecated public final MsearchRequest.Builder ignoreThrottled(@Nullable Boolean value)
      Deprecated.
      7.16.0 This parameter is deprecated because frozen indices have been deprecated.
      If true, concrete, expanded or aliased indices are ignored when frozen.

      API name: ignore_throttled

    • ignoreUnavailable

      public final MsearchRequest.Builder ignoreUnavailable(@Nullable Boolean value)
      If false, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If true, unavailable concrete targets are silently ignored.

      API name: ignore_unavailable

    • includeNamedQueriesScore

      public final MsearchRequest.Builder includeNamedQueriesScore(@Nullable Boolean value)
      Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) This functionality reruns each named query on every hit in a search response. Typically, this adds a small overhead to a request. However, using computationally expensive named queries on a large number of hits may add significant overhead.

      API name: include_named_queries_score

    • index

      public final MsearchRequest.Builder index(List<String> list)
      Comma-separated list of data streams, indices, and index aliases to search.

      API name: index

      Adds all elements of list to index.

    • index

      public final MsearchRequest.Builder index(String value, String... values)
      Comma-separated list of data streams, indices, and index aliases to search.

      API name: index

      Adds one or more values to index.

    • maxConcurrentSearches

      public final MsearchRequest.Builder maxConcurrentSearches(@Nullable Integer value)
      Maximum number of concurrent searches the multi search API can execute. Defaults to max(1, (# of data nodes * min(search thread pool size, 10))).

      API name: max_concurrent_searches

    • maxConcurrentShardRequests

      public final MsearchRequest.Builder maxConcurrentShardRequests(@Nullable Integer value)
      Maximum number of concurrent shard requests that each sub-search request executes per node.

      API name: max_concurrent_shard_requests

    • preFilterShardSize

      public final MsearchRequest.Builder preFilterShardSize(@Nullable Long value)
      Defines 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 i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint.

      API name: pre_filter_shard_size

    • projectRouting

      public final MsearchRequest.Builder projectRouting(@Nullable String value)
      Specifies a subset of projects to target for a search using project metadata tags in a subset Lucene syntax. Allowed Lucene queries: the _alias tag and a single value (possible wildcarded). Examples: _alias:my-project _alias:_origin _alias:pr Supported in serverless only.

      API name: project_routing

    • routeSlice

      public final MsearchRequest.Builder routeSlice(@Nullable String value)
      The slice identifier for routing the search to a specific slice. When provided at the top level, all sub-searches are routed to shards matching the given slice value. Use the special value _all to query all slices without restricting to a routing value. Required when index.slice.enabled is true for the target index; not allowed when index.slice.enabled is false. Individual sub-search headers can also specify _slice to override the top-level setting.

      API name: _slice

    • routing

      public final MsearchRequest.Builder routing(List<String> list)
      Custom routing value used to route search operations to a specific shard. Not allowed when index.slice.enabled is true for the target index; use _slice instead.

      API name: routing

      Adds all elements of list to routing.

    • routing

      public final MsearchRequest.Builder routing(String value, String... values)
      Custom routing value used to route search operations to a specific shard. Not allowed when index.slice.enabled is true for the target index; use _slice instead.

      API name: routing

      Adds one or more values to routing.

    • searchType

      public final MsearchRequest.Builder searchType(@Nullable SearchType value)
      Indicates whether global term and document frequencies should be used when scoring returned documents.

      API name: search_type

    • searches

      public final MsearchRequest.Builder searches(List<RequestItem> list)
      Required - Request body.

      Adds all elements of list to searches.

    • searches

      public final MsearchRequest.Builder searches(RequestItem value, RequestItem... values)
      Required - Request body.

      Adds one or more values to searches.

    • searches

      Required - Request body.

      Adds a value to searches using a builder lambda.

    • self

      protected MsearchRequest.Builder self()
      Specified by:
      self in class RequestBase.AbstractBuilder<MsearchRequest.Builder>
    • build

      public MsearchRequest build()
      Builds a MsearchRequest.
      Specified by:
      build in interface ObjectBuilder<MsearchRequest>
      Throws:
      NullPointerException - if some of the required fields are null.