summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java')
-rw-r--r--core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java80
1 files changed, 73 insertions, 7 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java
index 0d2801e44a..504a297627 100644
--- a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java
+++ b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java
@@ -29,8 +29,6 @@ import org.elasticsearch.action.support.single.instance.InstanceShardOperationRe
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.common.logging.DeprecationLogger;
-import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -52,8 +50,6 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
implements DocWriteRequest<UpdateRequest>, WriteRequest<UpdateRequest> {
- private static final DeprecationLogger DEPRECATION_LOGGER =
- new DeprecationLogger(Loggers.getLogger(UpdateRequest.class));
private String type;
private String id;
@@ -559,7 +555,9 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc to use for updates when a script is not specified.
+ * @deprecated use {@link #doc(String, XContentType)}
*/
+ @Deprecated
public UpdateRequest doc(String source) {
safeDoc().source(source);
return this;
@@ -568,6 +566,16 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc to use for updates when a script is not specified.
*/
+ public UpdateRequest doc(String source, XContentType xContentType) {
+ safeDoc().source(source, xContentType);
+ return this;
+ }
+
+ /**
+ * Sets the doc to use for updates when a script is not specified.
+ * @deprecated use {@link #doc(byte[], XContentType)}
+ */
+ @Deprecated
public UpdateRequest doc(byte[] source) {
safeDoc().source(source);
return this;
@@ -576,12 +584,30 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc to use for updates when a script is not specified.
*/
+ public UpdateRequest doc(byte[] source, XContentType xContentType) {
+ safeDoc().source(source, xContentType);
+ return this;
+ }
+
+ /**
+ * Sets the doc to use for updates when a script is not specified.
+ * @deprecated use {@link #doc(byte[], int, int, XContentType)}
+ */
+ @Deprecated
public UpdateRequest doc(byte[] source, int offset, int length) {
safeDoc().source(source, offset, length);
return this;
}
/**
+ * Sets the doc to use for updates when a script is not specified.
+ */
+ public UpdateRequest doc(byte[] source, int offset, int length, XContentType xContentType) {
+ safeDoc().source(source, offset, length, xContentType);
+ return this;
+ }
+
+ /**
* Sets the doc to use for updates when a script is not specified, the doc provided
* is a field and value pairs.
*/
@@ -591,10 +617,11 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
}
/**
- * 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.
*/
- public UpdateRequest doc(String field, Object value) {
- safeDoc().source(field, value);
+ public UpdateRequest doc(XContentType xContentType, Object... source) {
+ safeDoc().source(xContentType, source);
return this;
}
@@ -644,7 +671,9 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc source of the update request to be used when the document does not exists.
+ * @deprecated use {@link #upsert(String, XContentType)}
*/
+ @Deprecated
public UpdateRequest upsert(String source) {
safeUpsertRequest().source(source);
return this;
@@ -653,6 +682,16 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc source of the update request to be used when the document does not exists.
*/
+ public UpdateRequest upsert(String source, XContentType xContentType) {
+ safeUpsertRequest().source(source, xContentType);
+ return this;
+ }
+
+ /**
+ * Sets the doc source of the update request to be used when the document does not exists.
+ * @deprecated use {@link #upsert(byte[], XContentType)}
+ */
+ @Deprecated
public UpdateRequest upsert(byte[] source) {
safeUpsertRequest().source(source);
return this;
@@ -661,12 +700,30 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
/**
* Sets the doc source of the update request to be used when the document does not exists.
*/
+ public UpdateRequest upsert(byte[] source, XContentType xContentType) {
+ safeUpsertRequest().source(source, xContentType);
+ return this;
+ }
+
+ /**
+ * Sets the doc source of the update request to be used when the document does not exists.
+ * @deprecated use {@link #upsert(byte[], int, int, XContentType)}
+ */
+ @Deprecated
public UpdateRequest upsert(byte[] source, int offset, int length) {
safeUpsertRequest().source(source, offset, length);
return this;
}
/**
+ * Sets the doc source of the update request to be used when the document does not exists.
+ */
+ public UpdateRequest upsert(byte[] source, int offset, int length, XContentType xContentType) {
+ safeUpsertRequest().source(source, offset, length, xContentType);
+ return this;
+ }
+
+ /**
* Sets the doc source of the update request to be used when the document does not exists. The doc
* includes field and value pairs.
*/
@@ -675,6 +732,15 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
return this;
}
+ /**
+ * Sets the doc source of the update request to be used when the document does not exists. The doc
+ * includes field and value pairs.
+ */
+ public UpdateRequest upsert(XContentType xContentType, Object... source) {
+ safeUpsertRequest().source(xContentType, source);
+ return this;
+ }
+
public IndexRequest upsertRequest() {
return this.upsertRequest;
}