summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java')
-rw-r--r--core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java62
1 files changed, 58 insertions, 4 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java
index f7df8bffce..7af43ec35e 100644
--- a/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java
+++ b/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java
@@ -82,13 +82,23 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
/**
* Sets the source.
+ * @deprecated use {@link #setSource(BytesReference, XContentType)}
*/
+ @Deprecated
public IndexRequestBuilder setSource(BytesReference source) {
request.source(source);
return this;
}
/**
+ * Sets the source.
+ */
+ public IndexRequestBuilder setSource(BytesReference source, XContentType xContentType) {
+ request.source(source, xContentType);
+ return this;
+ }
+
+ /**
* Index the Map as a JSON.
*
* @param source The map to index
@@ -112,14 +122,27 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
* Sets the document source to index.
* <p>
* Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)}
- * or using the {@link #setSource(byte[])}.
+ * or using the {@link #setSource(byte[], XContentType)}.
+ * @deprecated use {@link #setSource(String, XContentType)}
*/
+ @Deprecated
public IndexRequestBuilder setSource(String source) {
request.source(source);
return this;
}
/**
+ * Sets the document source to index.
+ * <p>
+ * Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)}
+ * or using the {@link #setSource(byte[], XContentType)}.
+ */
+ public IndexRequestBuilder setSource(String source, XContentType xContentType) {
+ request.source(source, xContentType);
+ return this;
+ }
+
+ /**
* Sets the content source to index.
*/
public IndexRequestBuilder setSource(XContentBuilder sourceBuilder) {
@@ -129,26 +152,52 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
/**
* Sets the document to index in bytes form.
+ * @deprecated use {@link #setSource(byte[], XContentType)}
*/
+ @Deprecated
public IndexRequestBuilder setSource(byte[] source) {
request.source(source);
return this;
}
/**
+ * Sets the document to index in bytes form.
+ */
+ public IndexRequestBuilder setSource(byte[] source, XContentType xContentType) {
+ request.source(source, xContentType);
+ return this;
+ }
+
+ /**
* Sets the document to index in bytes form (assumed to be safe to be used from different
* threads).
*
* @param source The source to index
* @param offset The offset in the byte array
* @param length The length of the data
+ * @deprecated use {@link #setSource(byte[], int, int, XContentType)}
*/
+ @Deprecated
public IndexRequestBuilder setSource(byte[] source, int offset, int length) {
request.source(source, offset, length);
return this;
}
/**
+ * Sets the document to index in bytes form (assumed to be safe to be used from different
+ * threads).
+ *
+ * @param source The source to index
+ * @param offset The offset in the byte array
+ * @param length The length of the data
+ * @param xContentType The type/format of the source
+ */
+ public IndexRequestBuilder setSource(byte[] source, int offset, int length, XContentType xContentType) {
+ request.source(source, offset, length, xContentType);
+ return this;
+ }
+
+ /**
* Constructs a simple document with a field name and value pairs.
* <p>
* <b>Note: the number of objects passed to this method must be an even
@@ -162,10 +211,15 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
}
/**
- * The content type that will be used to generate a document from user provided objects (like Map).
+ * Constructs a simple document with a field name and value pairs.
+ * <p>
+ * <b>Note: the number of objects passed as varargs to this method must be an even
+ * number. Also the first argument in each pair (the field name) must have a
+ * valid String representation.</b>
+ * </p>
*/
- public IndexRequestBuilder setContentType(XContentType contentType) {
- request.contentType(contentType);
+ public IndexRequestBuilder setSource(XContentType xContentType, Object... source) {
+ request.source(xContentType, source);
return this;
}