Class MgetRequest

java.lang.Object
co.elastic.clients.elasticsearch._types.RequestBase
co.elastic.clients.elasticsearch.core.MgetRequest
All Implemented Interfaces:
JsonpSerializable

@JsonpDeserializable public class MgetRequest extends RequestBase implements JsonpSerializable
Get multiple documents.

Get multiple JSON documents by ID from one or more indices. If you specify an index in the request URI, you only need to specify the document IDs in the request body. To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.

Filter source fields

By default, the _source field is returned for every document (if stored). Use the _source and _source_include or source_exclude attributes to filter what fields are returned for a particular document. You can include the _source, _source_includes, and _source_excludes query parameters in the request URI to specify the defaults to use when there are no per-document instructions.

Get stored fields

Use the stored_fields attribute to specify the set of stored fields you want to retrieve. Any requested fields that are not stored are ignored. You can include the stored_fields query parameter in the request URI to specify the defaults to use when there are no per-document instructions.

See Also:
  • Field Details

  • Method Details

    • of

    • source

      @Nullable public final SourceConfigParam source()
      True or false to return the _source field or not, or a list of fields to return.

      API name: _source

    • sourceExcludes

      public final List<String> sourceExcludes()
      A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.

      API name: _source_excludes

    • sourceIncludes

      public final List<String> sourceIncludes()
      A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter. If the _source parameter is false, this parameter is ignored.

      API name: _source_includes

    • docs

      public final List<MultiGetOperation> docs()
      The documents you want to retrieve. Required if no index is specified in the request URI.

      API name: docs

    • forceSyntheticSource

      @Nullable public final Boolean forceSyntheticSource()
      Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index.

      API name: force_synthetic_source

    • ids

      public final List<String> ids()
      The IDs of the documents you want to retrieve. Allowed when the index is specified in the request URI.

      API name: ids

    • index

      @Nullable public final String index()
      Name of the index to retrieve documents from when ids are specified, or when a document in the docs array does not specify an index.

      API name: index

    • preference

      @Nullable public final String preference()
      Specifies the node or shard the operation should be performed on. Random by default.

      API name: preference

    • realtime

      @Nullable public final Boolean realtime()
      If true, the request is real-time as opposed to near-real-time.

      API name: realtime

    • refresh

      @Nullable public final Boolean refresh()
      If true, the request refreshes relevant shards before retrieving documents.

      API name: refresh

    • routing

      @Nullable public final String routing()
      Custom value used to route operations to a specific shard.

      API name: routing

    • storedFields

      public final List<String> storedFields()
      If true, retrieves the document fields stored in the index rather than the document _source.

      API name: stored_fields

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

      protected static void setupMgetRequestDeserializer(ObjectDeserializer<MgetRequest.Builder> op)
    • createMgetEndpoint

      public static <TDocument> Endpoint<MgetRequest,MgetResponse<TDocument>,ErrorResponse> createMgetEndpoint(JsonpDeserializer<TDocument> tDocumentDeserializer)
      Create an "mget" endpoint.