- All Implemented Interfaces:
org.apache.lucene.util.Accountable
,DocWriteRequest<UpdateRequest>
,IndicesRequest
,WriteRequest<UpdateRequest>
,Writeable
,RefCounted
,TaskAwareRequest
,ToXContent
,ToXContentObject
public class UpdateRequest
extends InstanceShardOperationRequest<UpdateRequest>
implements DocWriteRequest<UpdateRequest>, WriteRequest<UpdateRequest>, ToXContentObject
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.action.DocWriteRequest
DocWriteRequest.OpType
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.RemoteClusterShardRequest, IndicesRequest.Replaceable, IndicesRequest.SingleIndexNoWildcards
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
Nested classes/interfaces inherited from interface org.elasticsearch.action.support.WriteRequest
WriteRequest.RefreshPolicy
-
Field Summary
Fields inherited from class org.elasticsearch.action.support.single.instance.InstanceShardOperationRequest
DEFAULT_TIMEOUT, index, shardId, timeout
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
Fields inherited from interface org.elasticsearch.action.DocWriteRequest
LIST_EXECUTED_PIPELINES, REQUIRE_ALIAS, REQUIRE_DATA_STREAM
Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionUpdateRequest
(String index, String id) UpdateRequest
(ShardId shardId, StreamInput in) -
Method Summary
Modifier and TypeMethodDescriptionaddScriptParam
(String name, Object value) Deprecated.boolean
Should this update attempt to detect if it is a noop? Defaults to true.detectNoop
(boolean detectNoop) Should this update attempt to detect if it is a noop? Defaults to true.doc()
doc
(byte[] source, int offset, int length, XContentType xContentType) Sets the doc to use for updates when a script is not specified.doc
(byte[] source, XContentType xContentType) Sets the doc to use for updates when a script is not specified.Sets the doc to use for updates when a script is not specified, the doc provided is a field and value pairs.doc
(String source, XContentType xContentType) Sets the doc to use for updates when a script is not specified.Sets the doc to use for updates when a script is not specified.doc
(Map<String, Object> source, XContentType contentType) Sets the doc to use for updates when a script is not specified.doc
(IndexRequest doc) Sets the doc to use for updates when a script is not specified.doc
(BytesReference source, XContentType contentType) Sets the doc to use for updates when a script is not specified.doc
(XContentBuilder source) Sets the doc to use for updates when a script is not specified.doc
(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.boolean
docAsUpsert
(boolean shouldUpsertDoc) Gets theFetchSourceContext
which defines how the _source should be fetched.fetchSource
(boolean fetchSource) Indicates whether the response should contain the updated _source.fetchSource
(String[] includes, String[] excludes) Indicate that _source should be returned, with an "include" and/or "exclude" set which can include simple wildcard elements.fetchSource
(String include, String exclude) Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard elements.fetchSource
(FetchSourceContext context) Explicitly set the fetch source context for this requestfromXContent
(XContentParser parser) Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).id()
The id of the indexed document.Sets the id of the indexed document.long
If set, only perform this update request if the document was last modification was assigned this primary term.long
ifSeqNo()
If set, only perform this update request if the document was last modification was assigned this sequence number.boolean
Should this request override specifically require the destination to be an alias?boolean
Should this request override specifically require the destination to be a data stream?opType()
Get the requested document operation type of the requestvoid
process
(IndexRouting indexRouting) Finalize the request before executing or routing it.long
int
retryOnConflict
(int retryOnConflict) Sets the number of retries of a version conflict occurs because the document was updated between getting it and updating it.int
route
(IndexRouting indexRouting) Pick the appropriate shard id to receive this request.routing()
Controls the shard routing of the request.Controls the shard routing of the request.script()
Deprecated.Usescript(Script)
insteadDeprecated.Usescript(Script)
insteadscript
(String script, ScriptType scriptType) Deprecated.Usescript(Script)
insteadDeprecated.Usescript(Script)
insteadThe script to execute.boolean
scriptedUpsert
(boolean scriptedUpsert) Deprecated.Usescript()
insteadscriptLang
(String scriptLang) Deprecated.Usescript(Script)
insteadDeprecated.Usescript()
insteadscriptParams
(Map<String, Object> scriptParams) Deprecated.Usescript(Script)
insteadDeprecated.Usescript()
insteadDeprecated.Usescript()
insteadsetIfPrimaryTerm
(long term) only performs this update request if the document's last modification was assigned the given primary term.setIfSeqNo
(long seqNo) only perform this update request if the document's modification was assigned the given sequence number.setRefreshPolicy
(WriteRequest.RefreshPolicy refreshPolicy) Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).setRequireAlias
(boolean requireAlias) toString()
toXContent
(XContentBuilder builder, ToXContent.Params params) upsert
(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.upsert
(byte[] source, XContentType xContentType) Sets the doc source of the update request to be used when the document does not exists.Sets the doc source of the update request to be used when the document does not exists.upsert
(String source, XContentType xContentType) Sets the doc source of the update request to be used when the document does not exists.Sets the doc source of the update request to be used when the document does not exists.upsert
(Map<String, Object> source, XContentType contentType) Sets the doc source of the update request to be used when the document does not exists.upsert
(IndexRequest upsertRequest) Sets the index request to be used if the document does not exists.upsert
(BytesReference source, XContentType contentType) Sets the doc source of the update request to be used when the document does not exists.upsert
(XContentBuilder source) Sets the doc source of the update request to be used when the document does not exists.upsert
(XContentType xContentType, Object... source) Sets the doc source of the update request to be used when the document does not exists.validate()
long
version()
Get the document version for this requestversion
(long version) Sets the version, which will perform the operation only if a matching version exists and no changes happened on the doc since then.Get the document version type for this requestversionType
(VersionType versionType) Sets the versioning type.waitForActiveShards
(int waitForActiveShards) A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount.waitForActiveShards
(ActiveShardCount waitForActiveShards) Sets the number of shard copies that must be active before proceeding with the write.void
writeThin
(StreamOutput out) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.support.single.instance.InstanceShardOperationRequest
concreteIndex, index, index, indices, indicesOptions, timeout, timeout, timeout
Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, getRequestId, setParentTask, setRequestId
Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRef
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
Methods inherited from interface org.elasticsearch.action.DocWriteRequest
getConcreteWriteIndex, index, index, indicesOptions
Methods inherited from interface org.elasticsearch.action.IndicesRequest
includeDataStreams, indices
Methods inherited from interface org.elasticsearch.core.RefCounted
mustIncRef
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, getDescription, setParentTask
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
Methods inherited from interface org.elasticsearch.action.support.WriteRequest
setRefreshPolicy
-
Constructor Details
-
UpdateRequest
public UpdateRequest() -
UpdateRequest
- Throws:
IOException
-
UpdateRequest
- Throws:
IOException
-
UpdateRequest
-
-
Method Details
-
validate
- Specified by:
validate
in interfaceWriteRequest<UpdateRequest>
- Overrides:
validate
in classInstanceShardOperationRequest<UpdateRequest>
-
id
The id of the indexed document.- Specified by:
id
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the id
-
id
Sets the id of the indexed document. -
routing
Controls the shard routing of the request. Using this value to hash the shard and not the id.- Specified by:
routing
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the Request
-
routing
Controls the shard routing of the request. Using this value to hash the shard and not the id.- Specified by:
routing
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the Routing
-
getShardId
-
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. -
scriptString
Deprecated.Usescript()
instead -
scriptType
Deprecated.Usescript()
instead -
scriptParams
Deprecated.Usescript()
instead -
script
Deprecated.Usescript(Script)
insteadThe 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. -
script
Deprecated.Usescript(Script)
insteadThe 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. -
scriptLang
Deprecated.Usescript(Script)
insteadThe language of the script to execute. -
scriptLang
Deprecated.Usescript()
instead -
addScriptParam
Deprecated.Usescript(Script)
insteadAdd a script parameter. -
scriptParams
Deprecated.Usescript(Script)
insteadSets the script parameters to use with the script. -
script
@Deprecated public UpdateRequest script(String script, ScriptType scriptType, @Nullable Map<String, Object> scriptParams) Deprecated.Usescript(Script)
insteadThe 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. -
script
@Deprecated public UpdateRequest script(String script, @Nullable String scriptLang, ScriptType scriptType, @Nullable Map<String, Object> scriptParams) Deprecated.Usescript(Script)
insteadThe 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.- Parameters:
script
- The script to executescriptLang
- The script languagescriptType
- The script typescriptParams
- The script parameters
-
fetchSource
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 _sourceexclude
- An optional exclude (optionally wildcarded) pattern to filter the returned _source
-
fetchSource
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 _sourceexcludes
- An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
-
fetchSource
Indicates whether the response should contain the updated _source. -
fetchSource
Explicitly set the fetch source context for this request -
fetchSource
Gets theFetchSourceContext
which defines how the _source should be fetched. -
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. -
retryOnConflict
public int retryOnConflict() -
version
Description copied from interface:DocWriteRequest
Sets the version, which will perform the operation only if a matching version exists and no changes happened on the doc since then.- Specified by:
version
in interfaceDocWriteRequest<UpdateRequest>
-
version
public long version()Description copied from interface:DocWriteRequest
Get the document version for this request- Specified by:
version
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the document version
-
versionType
Description copied from interface:DocWriteRequest
Sets the versioning type. Defaults toVersionType.INTERNAL
.- Specified by:
versionType
in interfaceDocWriteRequest<UpdateRequest>
-
versionType
Description copied from interface:DocWriteRequest
Get the document version type for this request- Specified by:
versionType
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the document version type
-
setIfSeqNo
only perform this update request if the document's modification was assigned the given sequence number. Must be used in combination withsetIfPrimaryTerm(long)
If the document last modification was assigned a different sequence number aVersionConflictEngineException
will be thrown.- Specified by:
setIfSeqNo
in interfaceDocWriteRequest<UpdateRequest>
-
setIfPrimaryTerm
only performs this update request if the document's last modification was assigned the given primary term. Must be used in combination withsetIfSeqNo(long)
If the document last modification was assigned a different term aVersionConflictEngineException
will be thrown.- Specified by:
setIfPrimaryTerm
in interfaceDocWriteRequest<UpdateRequest>
-
ifSeqNo
public long ifSeqNo()If set, only perform this update request if the document was last modification was assigned this sequence number. If the document last modification was assigned a different sequence number aVersionConflictEngineException
will be thrown.- Specified by:
ifSeqNo
in interfaceDocWriteRequest<UpdateRequest>
-
ifPrimaryTerm
public long ifPrimaryTerm()If set, only perform this update request if the document was last modification was assigned this primary term. If the document last modification was assigned a different term aVersionConflictEngineException
will be thrown.- Specified by:
ifPrimaryTerm
in interfaceDocWriteRequest<UpdateRequest>
-
opType
Description copied from interface:DocWriteRequest
Get the requested document operation type of the request- Specified by:
opType
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- the operation type
DocWriteRequest.OpType
-
setRefreshPolicy
Description copied from interface:WriteRequest
Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).- Specified by:
setRefreshPolicy
in interfaceWriteRequest<UpdateRequest>
-
getRefreshPolicy
Description copied from interface:WriteRequest
Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).- Specified by:
getRefreshPolicy
in interfaceWriteRequest<UpdateRequest>
-
waitForActiveShards
-
waitForActiveShards
Sets the number of shard copies that must be active before proceeding with the write. SeeReplicationRequest.waitForActiveShards(ActiveShardCount)
for details. -
waitForActiveShards
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified. -
doc
Sets the doc to use for updates when a script is not specified, the doc provided is a field and value pairs. -
doc
Sets the doc to use for updates when a script is not specified. The doc is provided in a bytes form. -
doc
Sets the doc to use for updates when a script is not specified, the doc provided is a field and value pairs. -
doc
-
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the index request to be used if the document does not exists. Otherwise, aDocumentMissingException
is thrown. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. -
upsert
Sets the doc source of the update request to be used when the document does not exists. The doc includes field and value pairs. -
upsert
Sets the doc source of the update request to be used when the document does not exists. The doc includes field and value pairs. -
upsertRequest
-
detectNoop
Should this update attempt to detect if it is a noop? Defaults to true.- Returns:
- this for chaining
-
detectNoop
public boolean detectNoop()Should this update attempt to detect if it is a noop? Defaults to true. -
fromXContent
- Throws:
IOException
-
docAsUpsert
public boolean docAsUpsert() -
docAsUpsert
-
scriptedUpsert
public boolean scriptedUpsert() -
scriptedUpsert
-
isRequireAlias
public boolean isRequireAlias()Description copied from interface:DocWriteRequest
Should this request override specifically require the destination to be an alias?- Specified by:
isRequireAlias
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- boolean flag, when true specifically requires an alias
-
isRequireDataStream
public boolean isRequireDataStream()Description copied from interface:DocWriteRequest
Should this request override specifically require the destination to be a data stream?- Specified by:
isRequireDataStream
in interfaceDocWriteRequest<UpdateRequest>
- Returns:
- boolean flag, when true specifically requires a data stream
-
process
Description copied from interface:DocWriteRequest
Finalize the request before executing or routing it.- Specified by:
process
in interfaceDocWriteRequest<UpdateRequest>
-
route
Description copied from interface:DocWriteRequest
Pick the appropriate shard id to receive this request.- Specified by:
route
in interfaceDocWriteRequest<UpdateRequest>
-
setRequireAlias
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classInstanceShardOperationRequest<UpdateRequest>
- Throws:
IOException
-
writeThin
- Overrides:
writeThin
in classInstanceShardOperationRequest<UpdateRequest>
- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
toString
- Overrides:
toString
in classTransportRequest
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
script(Script)
instead