Package org.elasticsearch.action.index
Class IndexRequestBuilder
- java.lang.Object
-
- org.elasticsearch.action.ActionRequestBuilder<Request,Response,RequestBuilder>
-
- org.elasticsearch.action.support.replication.ReplicationRequestBuilder<IndexRequest,IndexResponse,IndexRequestBuilder>
-
- org.elasticsearch.action.index.IndexRequestBuilder
-
- All Implemented Interfaces:
WriteRequestBuilder<IndexRequestBuilder>
public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,IndexResponse,IndexRequestBuilder> implements WriteRequestBuilder<IndexRequestBuilder>
An index document action request builder.
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.action.ActionRequestBuilder
action, client, request
-
-
Constructor Summary
Constructors Constructor Description IndexRequestBuilder(ElasticsearchClient client, IndexAction action)IndexRequestBuilder(ElasticsearchClient client, IndexAction action, java.lang.String index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexRequestBuildersetCreate(boolean create)Set totrueto force this index to useDocWriteRequest.OpType.CREATE.IndexRequestBuildersetId(java.lang.String id)Sets the id to index the document under.IndexRequestBuildersetOpType(DocWriteRequest.OpType opType)Sets the type of operation to perform.IndexRequestBuildersetParent(java.lang.String parent)Sets the parent id of this document.IndexRequestBuildersetPipeline(java.lang.String pipeline)Sets the ingest pipeline to be executed before indexing the documentIndexRequestBuildersetRouting(java.lang.String routing)Controls the shard routing of the request.IndexRequestBuildersetSource(byte[] source, int offset, int length, XContentType xContentType)Sets the document to index in bytes form (assumed to be safe to be used from different threads).IndexRequestBuildersetSource(byte[] source, XContentType xContentType)Sets the document to index in bytes form.IndexRequestBuildersetSource(java.lang.Object... source)Constructs a simple document with a field name and value pairs.IndexRequestBuildersetSource(java.lang.String source, XContentType xContentType)Sets the document source to index.IndexRequestBuildersetSource(java.util.Map<java.lang.String,?> source)Index the Map as a JSON.IndexRequestBuildersetSource(java.util.Map<java.lang.String,?> source, XContentType contentType)Index the Map as the provided content type.IndexRequestBuildersetSource(BytesReference source, XContentType xContentType)Sets the source.IndexRequestBuildersetSource(XContentBuilder sourceBuilder)Sets the content source to index.IndexRequestBuildersetSource(XContentType xContentType, java.lang.Object... source)Constructs a simple document with a field name and value pairs.IndexRequestBuildersetType(java.lang.String type)Sets the type to index the document to.IndexRequestBuildersetVersion(long version)Sets the version, which will cause the index operation to only be performed if a matching version exists and no changes happened on the doc since then.IndexRequestBuildersetVersionType(VersionType versionType)Sets the versioning type.-
Methods inherited from class org.elasticsearch.action.ActionRequestBuilder
execute, execute, get, get, get, request
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class org.elasticsearch.action.support.replication.ReplicationRequestBuilder
setIndex, setTimeout, setTimeout, setWaitForActiveShards, setWaitForActiveShards
-
Methods inherited from interface org.elasticsearch.action.support.WriteRequestBuilder
request, setRefreshPolicy, setRefreshPolicy
-
-
-
-
Constructor Detail
-
IndexRequestBuilder
public IndexRequestBuilder(ElasticsearchClient client, IndexAction action)
-
IndexRequestBuilder
public IndexRequestBuilder(ElasticsearchClient client, IndexAction action, @Nullable java.lang.String index)
-
-
Method Detail
-
setType
public IndexRequestBuilder setType(java.lang.String type)
Sets the type to index the document to.
-
setId
public IndexRequestBuilder setId(java.lang.String id)
Sets the id to index the document under. Optional, and if not set, one will be automatically generated.
-
setRouting
public IndexRequestBuilder setRouting(java.lang.String routing)
Controls the shard routing of the request. Using this value to hash the shard and not the id.
-
setParent
public IndexRequestBuilder setParent(java.lang.String parent)
Sets the parent id of this document. If routing is not set, automatically set it as the routing as well.
-
setSource
public IndexRequestBuilder setSource(BytesReference source, XContentType xContentType)
Sets the source.
-
setSource
public IndexRequestBuilder setSource(java.util.Map<java.lang.String,?> source)
Index the Map as a JSON.- Parameters:
source- The map to index
-
setSource
public IndexRequestBuilder setSource(java.util.Map<java.lang.String,?> source, XContentType contentType)
Index the Map as the provided content type.- Parameters:
source- The map to index
-
setSource
public IndexRequestBuilder setSource(java.lang.String source, XContentType xContentType)
Sets the document source to index.Note, its preferable to either set it using
setSource(org.elasticsearch.common.xcontent.XContentBuilder)or using thesetSource(byte[], XContentType).
-
setSource
public IndexRequestBuilder setSource(XContentBuilder sourceBuilder)
Sets the content source to index.
-
setSource
public IndexRequestBuilder setSource(byte[] source, XContentType xContentType)
Sets the document to index in bytes form.
-
setSource
public IndexRequestBuilder setSource(byte[] source, int offset, int length, XContentType xContentType)
Sets the document to index in bytes form (assumed to be safe to be used from different threads).- Parameters:
source- The source to indexoffset- The offset in the byte arraylength- The length of the dataxContentType- The type/format of the source
-
setSource
public IndexRequestBuilder setSource(java.lang.Object... source)
Constructs a simple document with a field name and value pairs.Note: the number of objects passed to this method must be an even number. Also the first argument in each pair (the field name) must have a valid String representation.
-
setSource
public IndexRequestBuilder setSource(XContentType xContentType, java.lang.Object... source)
Constructs a simple document with a field name and value pairs.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.
-
setOpType
public IndexRequestBuilder setOpType(DocWriteRequest.OpType opType)
Sets the type of operation to perform.
-
setCreate
public IndexRequestBuilder setCreate(boolean create)
Set totrueto force this index to useDocWriteRequest.OpType.CREATE.
-
setVersion
public IndexRequestBuilder setVersion(long version)
Sets the version, which will cause the index operation to only be performed if a matching version exists and no changes happened on the doc since then.
-
setVersionType
public IndexRequestBuilder setVersionType(VersionType versionType)
Sets the versioning type. Defaults toVersionType.INTERNAL.
-
setPipeline
public IndexRequestBuilder setPipeline(java.lang.String pipeline)
Sets the ingest pipeline to be executed before indexing the document
-
-