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 String value)
      Unique identifier for the document.

      API name: id

    • ifPrimaryTerm

      public final IndexRequest.Builder<TDocument> ifPrimaryTerm(@Nullable Long value)
      Only perform the operation if the document has this primary term.

      API name: if_primary_term

    • ifSeqNo

      public final IndexRequest.Builder<TDocument> ifSeqNo(@Nullable Long value)
      Only perform the operation if the document has this sequence number.

      API name: if_seq_no

    • index

      public final IndexRequest.Builder<TDocument> index(String value)
      Required - Name of the data stream or index to target.

      API name: index

    • opType

      public final IndexRequest.Builder<TDocument> opType(@Nullable OpType value)
      Set to create to only index the document if it does not already exist (put if absent). If a document with the specified _id already exists, the indexing operation will fail. Same as using the <index>/_create endpoint. Valid values: index, create. If document id is specified, it defaults to index. Otherwise, it defaults to create.

      API name: op_type

    • pipeline

      public final IndexRequest.Builder<TDocument> pipeline(@Nullable String value)
      ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to _none disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter.

      API name: pipeline

    • refresh

      public final IndexRequest.Builder<TDocument> refresh(@Nullable Refresh value)
      If true, Elasticsearch refreshes 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 do nothing with refreshes. Valid values: true, false, wait_for.

      API name: refresh

    • requireAlias

      public final IndexRequest.Builder<TDocument> requireAlias(@Nullable Boolean value)
      If true, the destination must be an index alias.

      API name: require_alias

    • routing

      public final IndexRequest.Builder<TDocument> routing(@Nullable String value)
      Custom value used to route operations to a specific shard.

      API name: routing

    • timeout

      public final IndexRequest.Builder<TDocument> timeout(@Nullable Time value)
      Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.

      API name: timeout

    • timeout

      Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.

      API name: timeout

    • version

      public final IndexRequest.Builder<TDocument> version(@Nullable Long value)
      Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.

      API name: version

    • versionType

      public final IndexRequest.Builder<TDocument> versionType(@Nullable VersionType value)
      Specific version type: external, external_gte.

      API name: version_type

    • waitForActiveShards

      public final IndexRequest.Builder<TDocument> waitForActiveShards(@Nullable WaitForActiveShards value)
      The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1).

      API name: wait_for_active_shards

    • waitForActiveShards

      The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (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:
      NullPointerException - if some of the required fields are null.