java.lang.Object
org.elasticsearch.action.ActionRequestLazyBuilder<Request,Response>
org.elasticsearch.action.support.replication.ReplicationRequestBuilder<IndexRequest,DocWriteResponse,IndexRequestBuilder>
org.elasticsearch.action.index.IndexRequestBuilder
- All Implemented Interfaces:
RequestBuilder<IndexRequest,
,DocWriteResponse> WriteRequestBuilder<IndexRequestBuilder>
public class IndexRequestBuilder
extends ReplicationRequestBuilder<IndexRequest,DocWriteResponse,IndexRequestBuilder>
implements WriteRequestBuilder<IndexRequestBuilder>
An index document action request builder.
-
Field Summary
Fields inherited from class org.elasticsearch.action.ActionRequestLazyBuilder
action, client
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrequest()
This method creates the request.setCreate
(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 documentsetRefreshPolicy
(String refreshPolicy) Parse the refresh policy from a string, only modifying it if the string is non null.setRefreshPolicy
(WriteRequest.RefreshPolicy refreshPolicy) Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).setRequireAlias
(boolean requireAlias) Sets the require_alias flagsetRequireDataStream
(boolean requireDataStream) Sets the require_data_stream flagsetRouting
(String routing) Controls the shard routing of the request.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).setSource
(byte[] source, XContentType xContentType) Sets the document to index in bytes form.Constructs a simple document with a field name and value pairs.setSource
(String source, XContentType xContentType) Sets the document source to index.Index the Map as a JSON.setSource
(Map<String, ?> source, XContentType contentType) Index the Map as the provided content type.setSource
(BytesReference source, XContentType xContentType) Sets the source.setSource
(XContentBuilder sourceBuilder) Sets the content source to index.setSource
(XContentType xContentType, Object... source) Constructs a simple document with a field name and value pairs.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
apply, getIndex, setIndex, setTimeout, setTimeout, setWaitForActiveShards, setWaitForActiveShards
Methods inherited from class org.elasticsearch.action.ActionRequestLazyBuilder
execute, execute, get, get
-
Constructor Details
-
IndexRequestBuilder
-
IndexRequestBuilder
-
-
Method Details
-
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
Sets the source. -
setSource
Index the Map as a JSON.- Parameters:
source
- The map to index
-
setSource
Index the Map as the provided content type.- Parameters:
source
- The map to index
-
setSource
Sets the document source to index.Note, its preferable to either set it using
setSource(org.elasticsearch.xcontent.XContentBuilder)
or using thesetSource(byte[], XContentType)
. -
setSource
Sets the content source to index. -
setSource
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
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
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 -
setRequireDataStream
Sets the require_data_stream flag -
setRefreshPolicy
Description copied from interface:WriteRequestBuilder
Should this request trigger a refresh (WriteRequest.RefreshPolicy.IMMEDIATE), wait for a refresh ( WriteRequest.RefreshPolicy.WAIT_UNTIL), or proceed ignore refreshes entirely (WriteRequest.RefreshPolicy.NONE, the default).- Specified by:
setRefreshPolicy
in interfaceWriteRequestBuilder<IndexRequestBuilder>
-
setRefreshPolicy
Description copied from interface:WriteRequestBuilder
Parse the refresh policy from a string, only modifying it if the string is non null. Convenient to use with request parsing.- Specified by:
setRefreshPolicy
in interfaceWriteRequestBuilder<IndexRequestBuilder>
-
request
Description copied from class:ActionRequestLazyBuilder
This method creates the request. The caller of this method is responsible for calling Request#decRef.- Specified by:
request
in interfaceRequestBuilder<IndexRequest,
DocWriteResponse> - Specified by:
request
in interfaceWriteRequestBuilder<IndexRequestBuilder>
- Specified by:
request
in classActionRequestLazyBuilder<IndexRequest,
DocWriteResponse> - Returns:
- A newly-built Request, fully initialized by this builder.
-