Class UpdateRequest<TDocument,TPartialDocument> 
- All Implemented Interfaces:
- JsonpSerializable
Update a document by running a script or passing a partial document.
 If the Elasticsearch security features are enabled, you must have the
 index or write index privilege for the target index
 or index alias.
 
The script can update, delete, or skip modifying the document. The API also supports passing a partial document, which is merged into the existing document. To fully replace an existing document, use the index API. This operation:
- Gets the document (collocated with the shard) from the index.
- Runs the specified script.
- Indexes the result.
The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation.
 The _source field must be enabled to use this API. In addition
 to _source, you can access the following variables through the
 ctx map: _index, _type,
 _id, _version, _routing, and
 _now (the current timestamp). For usage examples such as partial
 updates, upserts, and scripted updates, see the External documentation.
- See Also:
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBaseRequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final JsonpDeserializer<UpdateRequest<Object,Object>> Json deserializer forUpdateRequestbased on named deserializers provided by the callingJsonMapper.static final SimpleEndpoint<UpdateRequest<?,?>, ?> Endpoint "update".
- 
Method SummaryModifier and TypeMethodDescriptionstatic <TDocument>
 Endpoint<UpdateRequest<?,?>, UpdateResponse<TDocument>, ErrorResponse> createUpdateEndpoint(JsonpDeserializer<TDocument> tDocumentDeserializer) Create an "update" endpoint.static <TDocument,TPartialDocument> 
 JsonpDeserializer<UpdateRequest<TDocument,TPartialDocument>> createUpdateRequestDeserializer(JsonpDeserializer<TDocument> tDocumentDeserializer, JsonpDeserializer<TPartialDocument> tPartialDocumentDeserializer) Create a JSON deserializer for UpdateRequestfinal BooleanIftrue, theresultin the response is set tonoop(no operation) when there are no changes to the document.final TPartialDocumentdoc()A partial update to an existing document.final BooleanIftrue, use the contents of 'doc' as the value of 'upsert'.final Stringid()Required - A unique identifier for the document to be updated.final LongOnly perform the operation if the document has this primary term.final LongifSeqNo()Only perform the operation if the document has this sequence number.final BooleanTrue or false if to include the document source in the error message in case of parsing errors.final Stringindex()Required - The name of the target index.final Stringlang()The script language.static <TDocument,TPartialDocument> 
 UpdateRequest<TDocument,TPartialDocument> of(Function<UpdateRequest.Builder<TDocument, TPartialDocument>, ObjectBuilder<UpdateRequest<TDocument, TPartialDocument>>> fn) final Refreshrefresh()If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search.final BooleanIftrue, the destination must be an index alias.final IntegerThe number of times the operation should be retried when a conflict occurs.final Stringrouting()A custom value used to route operations to a specific shard.final Scriptscript()The script to run to update the document.final BooleanIftrue, run the script whether or not the document exists.voidserialize(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) Serialize this object to JSON.protected voidserializeInternal(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) protected static <TDocument,TPartialDocument> 
 voidsetupUpdateRequestDeserializer(ObjectDeserializer<UpdateRequest.Builder<TDocument, TPartialDocument>> op, JsonpDeserializer<TDocument> tDocumentDeserializer, JsonpDeserializer<TPartialDocument> tPartialDocumentDeserializer) final SourceConfigsource()Iffalse, turn off source retrieval.final Timetimeout()The period to wait for the following operations: dynamic mapping updates and waiting for active shards.final TDocumentupsert()If the document does not already exist, the contents of 'upsert' are inserted as a new document.final WaitForActiveShardsThe number of copies of each shard that must be active before proceeding with the operation.Methods inherited from class co.elastic.clients.elasticsearch._types.RequestBasetoString
- 
Field Details- 
_DESERIALIZERJson deserializer forUpdateRequestbased on named deserializers provided by the callingJsonMapper.
- 
_ENDPOINTEndpoint "update".
 
- 
- 
Method Details- 
ofpublic static <TDocument,TPartialDocument> UpdateRequest<TDocument,TPartialDocument> of(Function<UpdateRequest.Builder<TDocument, TPartialDocument>, ObjectBuilder<UpdateRequest<TDocument, TPartialDocument>>> fn) 
- 
sourceIffalse, turn off source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.API name: _source
- 
detectNoopIftrue, theresultin the response is set tonoop(no operation) when there are no changes to the document.API name: detect_noop
- 
docA partial update to an existing document. If bothdocandscriptare specified,docis ignored.API name: doc
- 
docAsUpsertIftrue, use the contents of 'doc' as the value of 'upsert'. NOTE: Using ingest pipelines withdoc_as_upsertis not supported.API name: doc_as_upsert
- 
idRequired - A unique identifier for the document to be updated.API name: id
- 
ifPrimaryTermOnly perform the operation if the document has this primary term.API name: if_primary_term
- 
ifSeqNoOnly perform the operation if the document has this sequence number.API name: if_seq_no
- 
includeSourceOnErrorTrue or false if to include the document source in the error message in case of parsing errors.API name: include_source_on_error
- 
indexRequired - The name of the target index. By default, the index is created automatically if it doesn't exist.API name: index
- 
langThe script language.API name: lang
- 
refreshIf 'true', Elasticsearch refreshes the affected shards to make this operation visible to search. If 'wait_for', it waits for a refresh to make this operation visible to search. If 'false', it does nothing with refreshes.API name: refresh
- 
requireAliasIftrue, the destination must be an index alias.API name: require_alias
- 
retryOnConflictThe number of times the operation should be retried when a conflict occurs.API name: retry_on_conflict
- 
routingA custom value used to route operations to a specific shard.API name: routing
- 
scriptThe script to run to update the document.API name: script
- 
scriptedUpsertIftrue, run the script whether or not the document exists.API name: scripted_upsert
- 
timeoutThe period to wait for the following operations: dynamic mapping updates and waiting for active shards. Elasticsearch waits for at least the timeout period before failing. The actual wait time could be longer, particularly when multiple waits occur.API name: timeout
- 
upsertIf the document does not already exist, the contents of 'upsert' are inserted as a new document. If the document exists, the 'script' is run.API name: upsert
- 
waitForActiveShardsThe number of copies of each shard 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). The default value of1means it waits for each primary shard to be active.API name: wait_for_active_shards
- 
serializeSerialize this object to JSON.- Specified by:
- serializein interface- JsonpSerializable
 
- 
serializeInternal
- 
createUpdateRequestDeserializerpublic static <TDocument,TPartialDocument> JsonpDeserializer<UpdateRequest<TDocument,TPartialDocument>> createUpdateRequestDeserializer(JsonpDeserializer<TDocument> tDocumentDeserializer, JsonpDeserializer<TPartialDocument> tPartialDocumentDeserializer) Create a JSON deserializer for UpdateRequest
- 
setupUpdateRequestDeserializerprotected static <TDocument,TPartialDocument> void setupUpdateRequestDeserializer(ObjectDeserializer<UpdateRequest.Builder<TDocument, TPartialDocument>> op, JsonpDeserializer<TDocument> tDocumentDeserializer, JsonpDeserializer<TPartialDocument> tPartialDocumentDeserializer) 
- 
createUpdateEndpointpublic static <TDocument> Endpoint<UpdateRequest<?,?>, createUpdateEndpointUpdateResponse<TDocument>, ErrorResponse> (JsonpDeserializer<TDocument> tDocumentDeserializer) Create an "update" endpoint.
 
-