Class IndexRequest.Builder<TDocument>

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

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

    • Builder

      public Builder()
  • Method Details

    • id

      public final IndexRequest.Builder<TDocument> id​(@Nullable java.lang.String value)
      Document ID

      API name: id

    • ifPrimaryTerm

      public final IndexRequest.Builder<TDocument> ifPrimaryTerm​(@Nullable java.lang.Long value)
      only perform the index operation if the last operation that has changed the document has the specified primary term

      API name: if_primary_term

    • ifSeqNo

      public final IndexRequest.Builder<TDocument> ifSeqNo​(@Nullable java.lang.Long value)
      only perform the index operation if the last operation that has changed the document has the specified sequence number

      API name: if_seq_no

    • index

      public final IndexRequest.Builder<TDocument> index​(java.lang.String value)
      Required - The name of the index

      API name: index

    • opType

      public final IndexRequest.Builder<TDocument> opType​(@Nullable OpType value)
      Explicit operation type. Defaults to index for requests with an explicit document ID, and to createfor requests without an explicit document ID

      API name: op_type

    • pipeline

      public final IndexRequest.Builder<TDocument> pipeline​(@Nullable java.lang.String value)
      The pipeline id to preprocess incoming documents with

      API name: pipeline

    • refresh

      public final IndexRequest.Builder<TDocument> refresh​(@Nullable Refresh value)
      If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes.

      API name: refresh

    • requireAlias

      public final IndexRequest.Builder<TDocument> requireAlias​(@Nullable java.lang.Boolean value)
      When true, requires destination to be an alias. Default is false

      API name: require_alias

    • routing

      public final IndexRequest.Builder<TDocument> routing​(@Nullable java.lang.String value)
      Specific routing value

      API name: routing

    • timeout

      public final IndexRequest.Builder<TDocument> timeout​(@Nullable Time value)
      Explicit operation timeout

      API name: timeout

    • timeout

      public final IndexRequest.Builder<TDocument> timeout​(java.util.function.Function<Time.Builder,​ObjectBuilder<Time>> fn)
      Explicit operation timeout

      API name: timeout

    • version

      public final IndexRequest.Builder<TDocument> version​(@Nullable java.lang.Long value)
      Explicit version number for concurrency control

      API name: version

    • versionType

      public final IndexRequest.Builder<TDocument> versionType​(@Nullable VersionType value)
      Specific version type

      API name: version_type

    • waitForActiveShards

      public final IndexRequest.Builder<TDocument> waitForActiveShards​(@Nullable WaitForActiveShards value)
      Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)

      API name: wait_for_active_shards

    • waitForActiveShards

      public final IndexRequest.Builder<TDocument> waitForActiveShards​(java.util.function.Function<WaitForActiveShards.Builder,​ObjectBuilder<WaitForActiveShards>> fn)
      Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)

      API name: wait_for_active_shards

    • document

      public final IndexRequest.Builder<TDocument> document​(TDocument value)
      Required - Request body.
    • tDocumentSerializer

      public final IndexRequest.Builder<TDocument> tDocumentSerializer​(@Nullable JsonpSerializer<TDocument> value)
      Serializer for TDocument. If not set, an attempt will be made to find a serializer from the JSON context.
    • withJson

      public IndexRequest.Builder<TDocument> withJson​(jakarta.json.stream.JsonParser parser, JsonpMapper mapper)
      Description copied from interface: WithJson
      Sets additional properties values on this object by reading from a JSON input.

      This is a "partial deserialization": properties that were already set keep their value if they're not present in the JSON input, and properties can also be set after having called this method, including overriding those read from the JSON input.

      This low level variant of withJson gives full control on the json parser and object mapper. Most of the time using WithJson.withJson(Reader) and WithJson.withJson(InputStream) will be more convenient.

      Specified by:
      withJson in interface WithJson<TDocument>
      Overrides:
      withJson in class WithJsonObjectBuilderBase<IndexRequest.Builder<TDocument>>
      Parameters:
      parser - the JSONP parser
      mapper - the JSONP mapper used to deserialize values and nested objects
      Returns:
      this object
    • self

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

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