CompositeIndicesRequest, DocWriteRequest<IndexRequest>, IndicesRequest, WriteRequest<IndexRequest>, Streamable, Writeable, TaskAwareRequestpublic class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implements DocWriteRequest<IndexRequest>, CompositeIndicesRequest
Requests.indexRequest(String).
The index requires the ReplicationRequest.index(), type(String), id(String) and
source(byte[], XContentType) to be set.
The source (content to index) can be set in its bytes form using (source(byte[], XContentType)),
its string form (source(String, XContentType)) or using a XContentBuilder
(source(org.elasticsearch.common.xcontent.XContentBuilder)).
If the id(String) is not set, it will be automatically generated.DocWriteRequest.OpTypeIndicesRequest.ReplaceableTransportRequest.EmptyWriteable.Reader<V>, Writeable.Writer<V>WriteRequest.RefreshPolicy| Modifier and Type | Field | Description |
|---|---|---|
static int |
UNSET_AUTO_GENERATED_TIMESTAMP |
Value for
getAutoGeneratedTimestamp() if the document has an external
provided ID. |
DEFAULT_TIMEOUT, index, shardId, timeout, waitForActiveShards| Constructor | Description |
|---|---|
IndexRequest() |
|
IndexRequest(java.lang.String index) |
Constructs a new index request against the specific index.
|
IndexRequest(java.lang.String index,
java.lang.String type) |
Constructs a new index request against the specific index and type.
|
IndexRequest(java.lang.String index,
java.lang.String type,
java.lang.String id) |
Constructs a new index request against the index, type, id and using the source.
|
| Modifier and Type | Method | Description |
|---|---|---|
IndexRequest |
create(boolean create) |
Set to true to force this index to use
DocWriteRequest.OpType.CREATE. |
long |
getAutoGeneratedTimestamp() |
Returns the timestamp the auto generated ID was created or -1 if the
document has no auto generated timestamp.
|
XContentType |
getContentType() |
The content type.
|
java.lang.String |
getPipeline() |
Returns the ingest pipeline to be executed before indexing the document
|
java.lang.String |
id() |
The id of the indexed document.
|
IndexRequest |
id(java.lang.String id) |
Sets the id of the indexed document.
|
boolean |
isRetry() |
Returns
true if this request has been sent to a shard copy more than once. |
void |
onRetry() |
This method is called before this replication request is retried
the first time.
|
DocWriteRequest.OpType |
opType() |
Get the requested document operation type of the request
|
IndexRequest |
opType(java.lang.String opType) |
Sets a string representation of the
opType(OpType). |
IndexRequest |
opType(DocWriteRequest.OpType opType) |
Sets the type of operation to perform.
|
java.lang.String |
parent() |
Get the parent for this request
|
IndexRequest |
parent(java.lang.String parent) |
Sets the parent id of this document.
|
void |
process(Version indexCreatedVersion,
MappingMetaData mappingMd,
java.lang.String concreteIndex) |
|
void |
readFrom(StreamInput in) |
Set this object's fields from a StreamInput.
|
void |
resolveRouting(MetaData metaData) |
|
java.lang.String |
routing() |
Controls the shard routing of the request.
|
IndexRequest |
routing(java.lang.String routing) |
Controls the shard routing of the request.
|
IndexRequest |
setPipeline(java.lang.String pipeline) |
Sets the ingest pipeline to be executed before indexing the document
|
IndexRequest |
setShardId(ShardId shardId) |
Override this method from ReplicationAction, this is where we are storing our state in the request object (which we really shouldn't
do).
|
BytesReference |
source() |
The source of the document to index, recopied to a new array if it is unsafe.
|
IndexRequest |
source(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).
|
IndexRequest |
source(byte[] source,
XContentType xContentType) |
Sets the document to index in bytes form.
|
IndexRequest |
source(java.lang.Object... source) |
Sets the content source to index using the default content type (
Requests.INDEX_CONTENT_TYPE) |
IndexRequest |
source(java.lang.String source,
XContentType xContentType) |
Sets the document source to index.
|
IndexRequest |
source(java.util.Map source) |
Index the Map in
Requests.INDEX_CONTENT_TYPE format |
IndexRequest |
source(java.util.Map source,
XContentType contentType) |
Index the Map as the provided content type.
|
IndexRequest |
source(BytesReference source,
XContentType xContentType) |
Sets the document to index in bytes form.
|
IndexRequest |
source(XContentBuilder sourceBuilder) |
Sets the content source to index.
|
IndexRequest |
source(XContentType xContentType,
java.lang.Object... source) |
Sets the content source to index.
|
java.util.Map<java.lang.String,java.lang.Object> |
sourceAsMap() |
|
java.lang.String |
toString() |
|
java.lang.String |
type() |
The type of the indexed document.
|
IndexRequest |
type(java.lang.String type) |
Sets the type of the indexed document.
|
ActionRequestValidationException |
validate() |
|
long |
version() |
Returns stored version.
|
IndexRequest |
version(long version) |
Sets the version, which will perform the operation only if a matching
version exists and no changes happened on the doc since then.
|
VersionType |
versionType() |
Get the document version type for this request
|
IndexRequest |
versionType(VersionType versionType) |
Sets the versioning type.
|
void |
writeTo(StreamOutput out) |
Write this object's fields to a StreamOutput.
|
getShouldStoreResultindex, indicesOptionsindicesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRefreshPolicy, setRefreshPolicycreateTask, getDescription, index, index, indices, indicesOptions, shardId, timeout, timeout, timeout, waitForActiveShards, waitForActiveShards, waitForActiveShardssetParentTaskremoteAddress, remoteAddressgetParentTask, setParentTasksetRefreshPolicypublic static final int UNSET_AUTO_GENERATED_TIMESTAMP
getAutoGeneratedTimestamp() if the document has an external
provided ID.public IndexRequest()
public IndexRequest(java.lang.String index)
type(String)
source(byte[], XContentType) must be set.public IndexRequest(java.lang.String index,
java.lang.String type)
source(byte[], XContentType) must be set.public IndexRequest(java.lang.String index,
java.lang.String type,
java.lang.String id)
index - The index to index intotype - The type to index intoid - The id of documentpublic ActionRequestValidationException validate()
validate in interface WriteRequest<IndexRequest>validate in class ReplicationRequest<IndexRequest>public XContentType getContentType()
public java.lang.String type()
type in interface DocWriteRequest<IndexRequest>public IndexRequest type(java.lang.String type)
public java.lang.String id()
id in interface DocWriteRequest<IndexRequest>public IndexRequest id(java.lang.String id)
public IndexRequest routing(java.lang.String routing)
routing in interface DocWriteRequest<IndexRequest>public java.lang.String routing()
routing in interface DocWriteRequest<IndexRequest>public IndexRequest parent(java.lang.String parent)
public java.lang.String parent()
DocWriteRequestparent in interface DocWriteRequest<IndexRequest>public IndexRequest setPipeline(java.lang.String pipeline)
public java.lang.String getPipeline()
public BytesReference source()
public java.util.Map<java.lang.String,java.lang.Object> sourceAsMap()
public IndexRequest source(java.util.Map source) throws ElasticsearchGenerationException
Requests.INDEX_CONTENT_TYPE formatsource - The map to indexElasticsearchGenerationExceptionpublic IndexRequest source(java.util.Map source, XContentType contentType) throws ElasticsearchGenerationException
source - The map to indexElasticsearchGenerationExceptionpublic IndexRequest source(java.lang.String source, XContentType xContentType)
source(org.elasticsearch.common.xcontent.XContentBuilder)
or using the source(byte[], XContentType).public IndexRequest source(XContentBuilder sourceBuilder)
public IndexRequest source(java.lang.Object... source)
Requests.INDEX_CONTENT_TYPE)
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.
public IndexRequest source(XContentType xContentType, java.lang.Object... source)
Note: the number of objects passed to this method as varargs must be an even number. Also the first argument in each pair (the field name) must have a valid String representation.
public IndexRequest source(BytesReference source, XContentType xContentType)
public IndexRequest source(byte[] source, XContentType xContentType)
public IndexRequest source(byte[] source, int offset, int length, XContentType xContentType)
source - The source to indexoffset - The offset in the byte arraylength - The length of the datapublic IndexRequest opType(DocWriteRequest.OpType opType)
public IndexRequest opType(java.lang.String opType)
opType(OpType). Can
be either "index" or "create".public IndexRequest create(boolean create)
DocWriteRequest.OpType.CREATE.public DocWriteRequest.OpType opType()
DocWriteRequestopType in interface DocWriteRequest<IndexRequest>DocWriteRequest.OpTypepublic IndexRequest version(long version)
DocWriteRequestversion in interface DocWriteRequest<IndexRequest>public long version()
Versions.MATCH_ANY and
opType is DocWriteRequest.OpType.CREATE, returns Versions.MATCH_DELETED.version in interface DocWriteRequest<IndexRequest>public IndexRequest versionType(VersionType versionType)
DocWriteRequestVersionType.INTERNAL.versionType in interface DocWriteRequest<IndexRequest>public VersionType versionType()
DocWriteRequestversionType in interface DocWriteRequest<IndexRequest>public void process(Version indexCreatedVersion, @Nullable MappingMetaData mappingMd, java.lang.String concreteIndex)
public void resolveRouting(MetaData metaData)
public void readFrom(StreamInput in) throws java.io.IOException
StreamablereadFrom in interface StreamablereadFrom in class ReplicatedWriteRequest<IndexRequest>java.io.IOExceptionpublic void writeTo(StreamOutput out) throws java.io.IOException
StreamablewriteTo in interface StreamablewriteTo in interface WriteablewriteTo in class ReplicatedWriteRequest<IndexRequest>java.io.IOExceptionpublic java.lang.String toString()
toString in class ReplicationRequest<IndexRequest>public boolean isRetry()
true if this request has been sent to a shard copy more than once.public void onRetry()
ReplicationRequestonRetry in class ReplicationRequest<IndexRequest>public long getAutoGeneratedTimestamp()
public IndexRequest setShardId(ShardId shardId)
setShardId in class ReplicationRequest<IndexRequest>