public class IndexRequest extends ReplicationRequest<IndexRequest> implements DocumentRequest<IndexRequest>
Requests.indexRequest(String)
.
The index requires the ReplicationRequest.index()
, type(String)
, id(String)
and
source(byte[])
to be set.
The source (content to index) can be set in its bytes form using (source(byte[])
),
its string form (source(String)
) or using a XContentBuilder
(source(org.elasticsearch.common.xcontent.XContentBuilder)
).
If the id(String)
is not set, it will be automatically generated.
Modifier and Type | Class and Description |
---|---|
static class |
IndexRequest.OpType
Operation type controls if the type of the index operation.
|
TransportRequest.Empty
IndicesRequest.Replaceable
DEFAULT_TIMEOUT, index, shardId, timeout
headers
Constructor and Description |
---|
IndexRequest() |
IndexRequest(ActionRequest request)
Creates an index request caused by some other request, which is provided as an
argument so that its headers and context can be copied to the new request
|
IndexRequest(IndexRequest indexRequest,
ActionRequest originalRequest)
Copy constructor that creates a new index request that is a copy of the one provided as an argument.
|
IndexRequest(String index)
Constructs a new index request against the specific index.
|
IndexRequest(String index,
String type)
Constructs a new index request against the specific index and type.
|
IndexRequest(String index,
String type,
String id)
Constructs a new index request against the index, type, id and using the source.
|
Modifier and Type | Method and Description |
---|---|
boolean |
autoGeneratedId()
Has the id been auto generated?
|
IndexRequest |
contentType(XContentType contentType)
Sets the content type that will be used when generating a document from user provided objects (like Map).
|
IndexRequest |
create(boolean create)
Set to true to force this index to use
IndexRequest.OpType.CREATE . |
XContentType |
getContentType()
The content type that will be used when generating a document from user provided objects like Maps.
|
String |
id()
The id of the indexed document.
|
IndexRequest |
id(String id)
Sets the id of the indexed document.
|
IndexRequest.OpType |
opType()
The type of operation to perform.
|
IndexRequest |
opType(IndexRequest.OpType opType)
Sets the type of operation to perform.
|
IndexRequest |
opType(String opType)
Sets a string representation of the
opType(org.elasticsearch.action.index.IndexRequest.OpType) . |
String |
parent() |
IndexRequest |
parent(String parent)
Sets the parent id of this document.
|
void |
process(MetaData metaData,
MappingMetaData mappingMd,
boolean allowIdGeneration,
String concreteIndex) |
void |
readFrom(StreamInput in) |
boolean |
refresh() |
IndexRequest |
refresh(boolean refresh)
Should a refresh be executed post this index operation causing the operation to
be searchable.
|
String |
routing()
Controls the shard routing of the request.
|
IndexRequest |
routing(String routing)
Controls the shard routing of the request.
|
BytesReference |
source()
The source of the document to index, recopied to a new array if it is unsage.
|
IndexRequest |
source(byte[] source)
Sets the document to index in bytes form.
|
IndexRequest |
source(byte[] source,
int offset,
int length)
Sets the document to index in bytes form (assumed to be safe to be used from different
threads).
|
IndexRequest |
source(BytesReference source)
Sets the document to index in bytes form.
|
IndexRequest |
source(Map source)
Index the Map as a
Requests.INDEX_CONTENT_TYPE . |
IndexRequest |
source(Map source,
XContentType contentType)
Index the Map as the provided content type.
|
IndexRequest |
source(Object... source) |
IndexRequest |
source(String source)
Sets the document source to index.
|
IndexRequest |
source(String field1,
Object value1) |
IndexRequest |
source(String field1,
Object value1,
String field2,
Object value2) |
IndexRequest |
source(String field1,
Object value1,
String field2,
Object value2,
String field3,
Object value3) |
IndexRequest |
source(String field1,
Object value1,
String field2,
Object value2,
String field3,
Object value3,
String field4,
Object value4) |
IndexRequest |
source(XContentBuilder sourceBuilder)
Sets the content source to index.
|
Map<String,Object> |
sourceAsMap() |
String |
timestamp() |
IndexRequest |
timestamp(String timestamp)
Sets the timestamp either as millis since the epoch, or, in the configured date format.
|
String |
toString() |
TimeValue |
ttl() |
IndexRequest |
ttl(long ttl)
Sets the relative ttl value in milliseconds.
|
IndexRequest |
ttl(String ttl) |
IndexRequest |
ttl(TimeValue ttl) |
String |
type()
The type of the indexed document.
|
IndexRequest |
type(String type)
Sets the type of the indexed document.
|
ActionRequestValidationException |
validate() |
long |
version() |
IndexRequest |
version(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.
|
VersionType |
versionType() |
IndexRequest |
versionType(VersionType versionType)
Sets the versioning type.
|
void |
writeTo(StreamOutput out) |
canHaveDuplicates, consistencyLevel, consistencyLevel, createTask, getDescription, index, index, indices, indicesOptions, setShardId, shardId, timeout, timeout, timeout
createTask, setParentTask
remoteAddress, remoteAddress
contextSize, copyContextAndHeadersFrom, copyContextFrom, copyHeadersFrom, getContext, getFromContext, getFromContext, getHeader, getHeaders, hasHeader, hasInContext, isContextEmpty, putAllInContext, putHeader, putInContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
index, indicesOptions
indices
public IndexRequest()
public IndexRequest(ActionRequest request)
public IndexRequest(IndexRequest indexRequest, ActionRequest originalRequest)
public IndexRequest(String index)
type(String)
source(byte[])
must be set.public IndexRequest(String index, String type)
source(byte[])
must be set.public ActionRequestValidationException validate()
validate
in class ReplicationRequest<IndexRequest>
public XContentType getContentType()
public IndexRequest contentType(XContentType contentType)
public String type()
type
in interface DocumentRequest<IndexRequest>
public IndexRequest type(String type)
public String id()
id
in interface DocumentRequest<IndexRequest>
public IndexRequest id(String id)
public IndexRequest routing(String routing)
routing
in interface DocumentRequest<IndexRequest>
public String routing()
routing
in interface DocumentRequest<IndexRequest>
public IndexRequest parent(String parent)
public String parent()
public IndexRequest timestamp(String timestamp)
public String timestamp()
public IndexRequest ttl(long ttl) throws ElasticsearchGenerationException
ElasticsearchGenerationException
public IndexRequest ttl(String ttl)
public IndexRequest ttl(TimeValue ttl)
public TimeValue ttl()
public BytesReference source()
public IndexRequest source(Map source) throws ElasticsearchGenerationException
Requests.INDEX_CONTENT_TYPE
.source
- The map to indexElasticsearchGenerationException
public IndexRequest source(Map source, XContentType contentType) throws ElasticsearchGenerationException
source
- The map to indexElasticsearchGenerationException
public IndexRequest source(String source)
Note, its preferable to either set it using source(org.elasticsearch.common.xcontent.XContentBuilder)
or using the source(byte[])
.
public IndexRequest source(XContentBuilder sourceBuilder)
public IndexRequest source(String field1, Object value1)
public IndexRequest source(String field1, Object value1, String field2, Object value2)
public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3)
public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3, String field4, Object value4)
public IndexRequest source(Object... source)
public IndexRequest source(BytesReference source)
public IndexRequest source(byte[] source)
public IndexRequest source(byte[] source, int offset, int length)
source
- The source to indexoffset
- The offset in the byte arraylength
- The length of the datapublic IndexRequest opType(IndexRequest.OpType opType)
public IndexRequest opType(String opType)
opType(org.elasticsearch.action.index.IndexRequest.OpType)
. Can
be either "index" or "create".public IndexRequest create(boolean create)
IndexRequest.OpType.CREATE
.public IndexRequest.OpType opType()
public IndexRequest refresh(boolean refresh)
public boolean refresh()
public IndexRequest version(long version)
public long version()
public IndexRequest versionType(VersionType versionType)
VersionType.INTERNAL
.public VersionType versionType()
public boolean autoGeneratedId()
public void process(MetaData metaData, @Nullable MappingMetaData mappingMd, boolean allowIdGeneration, String concreteIndex)
public void readFrom(StreamInput in) throws IOException
readFrom
in interface Streamable
readFrom
in class ReplicationRequest<IndexRequest>
IOException
public void writeTo(StreamOutput out) throws IOException
writeTo
in interface Streamable
writeTo
in class ReplicationRequest<IndexRequest>
IOException
public String toString()
toString
in class ReplicationRequest<IndexRequest>
Copyright © 2009–2016. All rights reserved.