Package org.elasticsearch.action.index
Class IndexRequestBuilder
java.lang.Object
org.elasticsearch.action.ActionRequestBuilder<Request,Response>
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
ConstructorDescriptionIndexRequestBuilder(ElasticsearchClient client, IndexAction action)
IndexRequestBuilder(ElasticsearchClient client, IndexAction action, String index)
-
Method Summary
Modifier and TypeMethodDescriptionsetCreate(boolean create)
Set totrue
to force this index to useDocWriteRequest.OpType.CREATE
.Sets the id to index the document under.setIfPrimaryTerm(long term)
only perform this indexing request if the document was last modification was assigned the given primary term.setIfSeqNo(long seqNo)
only perform this indexing request if the document was last modification was assigned the given sequence number.setOpType(DocWriteRequest.OpType opType)
Sets the type of operation to perform.setPipeline(String pipeline)
Sets the ingest pipeline to be executed before indexing the documentsetRequireAlias(boolean requireAlias)
Sets the require_alias flagsetRouting(String routing)
Controls the shard routing of the request.setSource(byte[] source, int offset, int length, org.elasticsearch.common.xcontent.XContentType xContentType)
Sets the document to index in bytes form (assumed to be safe to be used from different threads).setSource(byte[] source, org.elasticsearch.common.xcontent.XContentType xContentType)
Sets the document to index in bytes form.Constructs a simple document with a field name and value pairs.Sets the document source to index.Index the Map as a JSON.Index the Map as the provided content type.setSource(BytesReference source, org.elasticsearch.common.xcontent.XContentType xContentType)
Sets the source.setSource(org.elasticsearch.common.xcontent.XContentBuilder sourceBuilder)
Sets the content source to index.Constructs a simple document with a field name and value pairs.Sets the type to index the document to.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(VersionType versionType)
Sets the versioning type.Methods inherited from class org.elasticsearch.action.support.replication.ReplicationRequestBuilder
setIndex, setTimeout, setTimeout, setWaitForActiveShards, setWaitForActiveShards
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 interface org.elasticsearch.action.support.WriteRequestBuilder
request, setRefreshPolicy, setRefreshPolicy
-
Constructor Details
-
IndexRequestBuilder
-
IndexRequestBuilder
-
-
Method Details
-
setType
Sets the type to index the document to. -
setId
Sets the id to index the document under. Optional, and if not set, one will be automatically generated. -
setRouting
Controls the shard routing of the request. Using this value to hash the shard and not the id. -
setSource
public IndexRequestBuilder setSource(BytesReference source, org.elasticsearch.common.xcontent.XContentType xContentType)Sets the source. -
setSource
Index the Map as a JSON.- Parameters:
source
- The map to index
-
setSource
public IndexRequestBuilder setSource(Map<String,?> source, org.elasticsearch.common.xcontent.XContentType contentType)Index the Map as the provided content type.- Parameters:
source
- The map to index
-
setSource
public IndexRequestBuilder setSource(String source, org.elasticsearch.common.xcontent.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(org.elasticsearch.common.xcontent.XContentBuilder sourceBuilder)Sets the content source to index. -
setSource
public IndexRequestBuilder setSource(byte[] source, org.elasticsearch.common.xcontent.XContentType xContentType)Sets the document to index in bytes form. -
setSource
public IndexRequestBuilder setSource(byte[] source, int offset, int length, org.elasticsearch.common.xcontent.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
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(org.elasticsearch.common.xcontent.XContentType xContentType, 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
Sets the type of operation to perform. -
setCreate
Set totrue
to force this index to useDocWriteRequest.OpType.CREATE
. -
setVersion
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
Sets the versioning type. Defaults toVersionType.INTERNAL
. -
setIfSeqNo
only perform this indexing request if the document was last 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. -
setIfPrimaryTerm
only perform this indexing request if the document was 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. -
setPipeline
Sets the ingest pipeline to be executed before indexing the document -
setRequireAlias
Sets the require_alias flag
-