org.elasticsearch.action.update
Class UpdateRequest

java.lang.Object
  extended by org.elasticsearch.action.support.single.instance.InstanceShardOperationRequest
      extended by org.elasticsearch.action.update.UpdateRequest
All Implemented Interfaces:
ActionRequest, Streamable

public class UpdateRequest
extends InstanceShardOperationRequest


Field Summary
 
Fields inherited from class org.elasticsearch.action.support.single.instance.InstanceShardOperationRequest
DEFAULT_TIMEOUT, index, shardId, timeout
 
Constructor Summary
UpdateRequest(String index, String type, String id)
           
 
Method Summary
 UpdateRequest addScriptParam(String name, Object value)
          Add a script parameter.
 WriteConsistencyLevel consistencyLevel()
           
 UpdateRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
          Sets the consistency level of write.
 IndexRequest doc()
           
 UpdateRequest doc(byte[] source)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(byte[] source, int offset, int length)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(IndexRequest doc)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(Map source)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(Map source, XContentType contentType)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(String source)
          Sets the doc to use for updates when a script is not specified.
 UpdateRequest doc(XContentBuilder source)
          Sets the doc to use for updates when a script is not specified.
 String[] fields()
          Get the fields to be returned.
 UpdateRequest fields(String... fields)
          Explicitly specify the fields that will be returned.
 String id()
          The id of the indexed document.
 UpdateRequest id(String id)
          Sets the id of the indexed document.
 UpdateRequest index(String index)
          Sets the index the document will exists on.
 UpdateRequest parent(String parent)
          Sets the parent id of this document.
 String percolate()
           
 UpdateRequest percolate(String percolate)
          Causes the update request document to be percolated.
 void readFrom(StreamInput in)
           
 boolean refresh()
           
 UpdateRequest refresh(boolean refresh)
          Should a refresh be executed post this update operation causing the operation to be searchable.
 ReplicationType replicationType()
          The replication type.
 UpdateRequest replicationType(ReplicationType replicationType)
          Sets the replication type.
 int retryOnConflict()
           
 UpdateRequest retryOnConflict(int retryOnConflict)
          Sets the number of retries of a version conflict occurs because the document was updated between getting it and updating it.
 String routing()
          Controls the shard routing of the request.
 UpdateRequest routing(String routing)
          Controls the shard routing of the request.
 String script()
           
 UpdateRequest script(String script)
          The script to execute.
 UpdateRequest script(String script, Map<String,Object> scriptParams)
          The script to execute.
 UpdateRequest script(String script, String scriptLang, Map<String,Object> scriptParams)
          The script to execute.
 UpdateRequest scriptLang(String scriptLang)
          The language of the script to execute.
 Map<String,Object> scriptParams()
           
 UpdateRequest scriptParams(Map<String,Object> scriptParams)
          Sets the script parameters to use with the script.
 UpdateRequest source(byte[] source)
           
 UpdateRequest source(byte[] source, int offset, int length)
           
 UpdateRequest source(BytesReference source)
           
 UpdateRequest source(XContentBuilder source)
           
 UpdateRequest timeout(String timeout)
          A timeout to wait if the index operation can't be performed immediately.
 UpdateRequest timeout(TimeValue timeout)
          A timeout to wait if the index operation can't be performed immediately.
 String type()
          The type of the indexed document.
 UpdateRequest type(String type)
          Sets the type of the indexed document.
 UpdateRequest upsert(byte[] source)
          Sets the doc source of the update request to be used when the document does not exists.
 UpdateRequest upsert(byte[] source, int offset, int length)
          Sets the doc source of the update request to be used when the document does not exists.
 UpdateRequest upsert(IndexRequest upsertRequest)
          Sets the index request to be used if the document does not exists.
 UpdateRequest upsert(Map source)
          Sets the doc source of the update request to be used when the document does not exists.
 UpdateRequest upsert(Map source, XContentType contentType)
          Sets the doc source of the update request to be used when the document does not exists.
 UpdateRequest upsert(String source)
          Sets the doc source of the update request to be used when the document does not exists.
 UpdateRequest upsert(XContentBuilder source)
          Sets the doc source of the update request to be used when the document does not exists.
 IndexRequest upsertRequest()
           
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.action.support.single.instance.InstanceShardOperationRequest
beforeLocalFork, index, listenerThreaded, listenerThreaded, timeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateRequest

public UpdateRequest(String index,
                     String type,
                     String id)
Method Detail

validate

public ActionRequestValidationException validate()
Specified by:
validate in interface ActionRequest
Overrides:
validate in class InstanceShardOperationRequest

index

public UpdateRequest index(String index)
Sets the index the document will exists on.


type

public String type()
The type of the indexed document.


type

public UpdateRequest type(String type)
Sets the type of the indexed document.


id

public String id()
The id of the indexed document.


id

public UpdateRequest id(String id)
Sets the id of the indexed document.


routing

public UpdateRequest routing(String routing)
Controls the shard routing of the request. Using this value to hash the shard and not the id.


parent

public UpdateRequest parent(String parent)
Sets the parent id of this document. Will simply set the routing to this value, as it is only used for routing with delete requests.


routing

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


script

public String script()

scriptParams

public Map<String,Object> scriptParams()

script

public UpdateRequest script(String 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.


scriptLang

public UpdateRequest scriptLang(String scriptLang)
The language of the script to execute.


addScriptParam

public UpdateRequest addScriptParam(String name,
                                    Object value)
Add a script parameter.


scriptParams

public UpdateRequest scriptParams(Map<String,Object> scriptParams)
Sets the script parameters to use with the script.


script

public UpdateRequest script(String script,
                            @Nullable
                            Map<String,Object> scriptParams)
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.


script

public UpdateRequest script(String script,
                            @Nullable
                            String scriptLang,
                            @Nullable
                            Map<String,Object> scriptParams)
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.

Parameters:
script - The script to execute
scriptLang - The script language
scriptParams - The script parameters

fields

public UpdateRequest fields(String... fields)
Explicitly specify the fields that will be returned. By default, nothing is returned.


fields

public String[] fields()
Get the fields to be returned.


retryOnConflict

public UpdateRequest retryOnConflict(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 1.


retryOnConflict

public int retryOnConflict()

percolate

public UpdateRequest percolate(String percolate)
Causes the update request document to be percolated. The parameter is the percolate query to use to reduce the percolated queries that are going to run against this doc. Can be set to * to indicate that all percolate queries should be run.


percolate

public String percolate()

timeout

public UpdateRequest timeout(TimeValue timeout)
A timeout to wait if the index operation can't be performed immediately. Defaults to 1m.


timeout

public UpdateRequest timeout(String timeout)
A timeout to wait if the index operation can't be performed immediately. Defaults to 1m.


refresh

public UpdateRequest refresh(boolean refresh)
Should a refresh be executed post this update operation causing the operation to be searchable. Note, heavy indexing should not set this to true. Defaults to false.


refresh

public boolean refresh()

replicationType

public ReplicationType replicationType()
The replication type.


replicationType

public UpdateRequest replicationType(ReplicationType replicationType)
Sets the replication type.


consistencyLevel

public WriteConsistencyLevel consistencyLevel()

consistencyLevel

public UpdateRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
Sets the consistency level of write. Defaults to WriteConsistencyLevel.DEFAULT


doc

public UpdateRequest doc(IndexRequest doc)
Sets the doc to use for updates when a script is not specified.


doc

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


doc

public UpdateRequest doc(Map source)
Sets the doc to use for updates when a script is not specified.


doc

public UpdateRequest doc(Map source,
                         XContentType contentType)
Sets the doc to use for updates when a script is not specified.


doc

public UpdateRequest doc(String source)
Sets the doc to use for updates when a script is not specified.


doc

public UpdateRequest doc(byte[] source)
Sets the doc to use for updates when a script is not specified.


doc

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


doc

public IndexRequest doc()

upsert

public UpdateRequest upsert(IndexRequest upsertRequest)
Sets the index request to be used if the document does not exists. Otherwise, a DocumentMissingException is thrown.


upsert

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


upsert

public UpdateRequest upsert(Map source)
Sets the doc source of the update request to be used when the document does not exists.


upsert

public UpdateRequest upsert(Map source,
                            XContentType contentType)
Sets the doc source of the update request to be used when the document does not exists.


upsert

public UpdateRequest upsert(String source)
Sets the doc source of the update request to be used when the document does not exists.


upsert

public UpdateRequest upsert(byte[] source)
Sets the doc source of the update request to be used when the document does not exists.


upsert

public UpdateRequest upsert(byte[] source,
                            int offset,
                            int length)
Sets the doc source of the update request to be used when the document does not exists.


upsertRequest

public IndexRequest upsertRequest()

source

public UpdateRequest source(XContentBuilder source)
                     throws Exception
Throws:
Exception

source

public UpdateRequest source(byte[] source)
                     throws Exception
Throws:
Exception

source

public UpdateRequest source(byte[] source,
                            int offset,
                            int length)
                     throws Exception
Throws:
Exception

source

public UpdateRequest source(BytesReference source)
                     throws Exception
Throws:
Exception

readFrom

public void readFrom(StreamInput in)
              throws IOException
Specified by:
readFrom in interface Streamable
Overrides:
readFrom in class InstanceShardOperationRequest
Throws:
IOException

writeTo

public void writeTo(StreamOutput out)
             throws IOException
Specified by:
writeTo in interface Streamable
Overrides:
writeTo in class InstanceShardOperationRequest
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.