Class UpdateRequestBuilder

All Implemented Interfaces:
WriteRequestBuilder<UpdateRequestBuilder>

  • Constructor Details

  • Method Details

    • setType

      public UpdateRequestBuilder setType(String type)
      Sets the type of the indexed document.
    • setId

      public UpdateRequestBuilder setId(String id)
      Sets the id of the indexed document.
    • setRouting

      public UpdateRequestBuilder setRouting(String routing)
      Controls the shard routing of the request. Using this value to hash the shard and not the id.
    • setScript

      public UpdateRequestBuilder setScript(Script script)
      The script to execute. Note, make sure not to send different script each times and instead use script params if possible with the same (automatically compiled) script.

      The script works with the variable ctx, which is bound to the entry, e.g. ctx._source.mycounter += 1.

    • setFetchSource

      public UpdateRequestBuilder setFetchSource(@Nullable String include, @Nullable String exclude)
      Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.
      Parameters:
      include - An optional include (optionally wildcarded) pattern to filter the returned _source
      exclude - An optional exclude (optionally wildcarded) pattern to filter the returned _source
    • setFetchSource

      public UpdateRequestBuilder setFetchSource(@Nullable String[] includes, @Nullable String[] excludes)
      Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.
      Parameters:
      includes - An optional list of include (optionally wildcarded) pattern to filter the returned _source
      excludes - An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
    • setFetchSource

      public UpdateRequestBuilder setFetchSource(boolean fetchSource)
      Indicates whether the response should contain the updated _source.
    • setRetryOnConflict

      public UpdateRequestBuilder setRetryOnConflict(int retryOnConflict)
      Sets the number of retries of a version conflict occurs because the document was updated between getting it and updating it. Defaults to 0.
    • setVersion

      public UpdateRequestBuilder setVersion(long version)
      Sets the version, which will cause the index operation to only be performed if a matching version exists and no changes happened on the doc since then.
    • setVersionType

      public UpdateRequestBuilder setVersionType(VersionType versionType)
      Sets the versioning type. Defaults to VersionType.INTERNAL.
    • setIfSeqNo

      public UpdateRequestBuilder setIfSeqNo(long seqNo)
      only perform this update request if the document was last modification was assigned the given sequence number. Must be used in combination with setIfPrimaryTerm(long) If the document last modification was assigned a different sequence number a VersionConflictEngineException will be thrown.
    • setIfPrimaryTerm

      public UpdateRequestBuilder setIfPrimaryTerm(long term)
      only perform this update request if the document was last modification was assigned the given primary term. Must be used in combination with setIfSeqNo(long) If the document last modification was assigned a different term a VersionConflictEngineException will be thrown.
    • setWaitForActiveShards

      public UpdateRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShards)
      Sets the number of shard copies that must be active before proceeding with the write. See ReplicationRequest.waitForActiveShards(ActiveShardCount) for details.
    • setWaitForActiveShards

      public UpdateRequestBuilder setWaitForActiveShards(int waitForActiveShards)
      A shortcut for setWaitForActiveShards(ActiveShardCount) where the numerical shard count is passed in, instead of having to first call ActiveShardCount.from(int) to get the ActiveShardCount.
    • setDoc

      public UpdateRequestBuilder setDoc(IndexRequest indexRequest)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(XContentBuilder source)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(Map<String,Object> source)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(Map<String,Object> source, XContentType contentType)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(String source, XContentType xContentType)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(byte[] source, XContentType xContentType)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(byte[] source, int offset, int length, XContentType xContentType)
      Sets the doc to use for updates when a script is not specified.
    • setDoc

      public UpdateRequestBuilder setDoc(Object... source)
      Sets the doc to use for updates when a script is not specified, the doc provided is a field and value pairs.
    • setDoc

      public UpdateRequestBuilder setDoc(XContentType xContentType, Object... source)
      Sets the doc to use for updates when a script is not specified, the doc provided is a field and value pairs.
    • setUpsert

      public UpdateRequestBuilder setUpsert(IndexRequest indexRequest)
      Sets the index request to be used if the document does not exists. Otherwise, a DocumentMissingException is thrown.
    • setUpsert

      public UpdateRequestBuilder setUpsert(XContentBuilder source)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(Map<String,Object> source)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(Map<String,Object> source, XContentType contentType)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(String source, XContentType xContentType)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(byte[] source, XContentType xContentType)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length, XContentType xContentType)
      Sets the doc source of the update request to be used when the document does not exists.
    • setUpsert

      public UpdateRequestBuilder setUpsert(Object... source)
      Sets the doc source of the update request to be used when the document does not exists. The doc includes field and value pairs.
    • setUpsert

      public UpdateRequestBuilder setUpsert(XContentType xContentType, Object... source)
      Sets the doc source of the update request to be used when the document does not exists. The doc includes field and value pairs.
    • setDocAsUpsert

      public UpdateRequestBuilder setDocAsUpsert(boolean shouldUpsertDoc)
      Sets whether the specified doc parameter should be used as upsert document.
    • setDetectNoop

      public UpdateRequestBuilder setDetectNoop(boolean detectNoop)
      Sets whether to perform extra effort to detect noop updates via docAsUpsert. Defaults to true.
    • setScriptedUpsert

      public UpdateRequestBuilder setScriptedUpsert(boolean scriptedUpsert)
      Sets whether the script should be run in the case of an insert