|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.elasticsearch.action.support.replication.ShardReplicationOperationRequest org.elasticsearch.action.index.IndexRequest
public class IndexRequest
Index request to index a typed JSON document into a specific index and make it searchable. Best
created using Requests.indexRequest(String)
.
The index requires the ShardReplicationOperationRequest.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.
IndexResponse
,
Requests.indexRequest(String)
,
Client.index(IndexRequest)
Nested Class Summary | |
---|---|
static class |
IndexRequest.OpType
Operation type controls if the type of the index operation. |
Field Summary |
---|
Fields inherited from class org.elasticsearch.action.support.replication.ShardReplicationOperationRequest |
---|
DEFAULT_TIMEOUT, index, timeout |
Constructor Summary | |
---|---|
IndexRequest()
|
|
IndexRequest(java.lang.String index)
Constructs a new index request against the specific index. |
|
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. |
Method Summary | |
---|---|
void |
beforeLocalFork()
Before we fork on a local thread, make sure we copy over the bytes if they are unsafe |
IndexRequest |
consistencyLevel(WriteConsistencyLevel consistencyLevel)
Sets the consistency level of write. |
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 . |
java.lang.String |
id()
The id of the indexed document. |
IndexRequest |
id(java.lang.String id)
Sets the id of the indexed document. |
IndexRequest |
index(java.lang.String index)
Sets the index the index operation will happen on. |
IndexRequest |
listenerThreaded(boolean threadedListener)
Should the listener be called on a separate thread if needed. |
IndexRequest |
operationThreaded(boolean threadedOperation)
Controls if the operation will be executed on a separate thread when executed locally. |
IndexRequest.OpType |
opType()
The type of operation to perform. |
IndexRequest |
opType(IndexRequest.OpType opType)
Sets the type of operation to perform. |
IndexRequest |
opType(java.lang.String opType)
Sets a string representation of the opType(org.elasticsearch.action.index.IndexRequest.OpType) . |
java.lang.String |
parent()
|
IndexRequest |
parent(java.lang.String parent)
Sets the parent id of this document. |
java.lang.String |
percolate()
|
IndexRequest |
percolate(java.lang.String percolate)
Causes the index request document to be percolated. |
void |
process(MetaData metaData,
java.lang.String aliasOrIndex,
MappingMetaData mappingMd,
boolean allowIdGeneration)
|
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. |
IndexRequest |
replicationType(ReplicationType replicationType)
Set the replication type for this operation. |
IndexRequest |
replicationType(java.lang.String replicationType)
Set the replication type for this operation. |
java.lang.String |
routing()
Controls the shard routing of the request. |
IndexRequest |
routing(java.lang.String routing)
Controls the shard routing of the request. |
byte[] |
source()
The source of the document to index, recopied to a new array if it has an offset or unsafe. |
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(byte[] source,
int offset,
int length,
boolean unsafe)
Sets the document to index in bytes form. |
IndexRequest |
source(java.util.Map source)
Index the Map as a Requests.INDEX_CONTENT_TYPE . |
IndexRequest |
source(java.util.Map source,
XContentType contentType)
Index the Map as the provided content type. |
IndexRequest |
source(java.lang.String source)
Sets the document source to index. |
IndexRequest |
source(java.lang.String field1,
java.lang.Object value1)
|
IndexRequest |
source(java.lang.String field1,
java.lang.Object value1,
java.lang.String field2,
java.lang.Object value2)
|
IndexRequest |
source(java.lang.String field1,
java.lang.Object value1,
java.lang.String field2,
java.lang.Object value2,
java.lang.String field3,
java.lang.Object value3)
|
IndexRequest |
source(java.lang.String field1,
java.lang.Object value1,
java.lang.String field2,
java.lang.Object value2,
java.lang.String field3,
java.lang.Object value3,
java.lang.String field4,
java.lang.Object value4)
|
IndexRequest |
source(XContentBuilder sourceBuilder)
Sets the content source to index. |
IndexRequest |
timeout(java.lang.String timeout)
A timeout to wait if the index operation can't be performed immediately. |
IndexRequest |
timeout(TimeValue timeout)
A timeout to wait if the index operation can't be performed immediately. |
java.lang.String |
timestamp()
|
IndexRequest |
timestamp(java.lang.String timestamp)
Sets the timestamp either as millis since the epoch, or, in the configured date format. |
java.lang.String |
toString()
|
long |
ttl()
|
IndexRequest |
ttl(java.lang.Long ttl)
Sets the relative ttl value. |
java.lang.String |
type()
The type of the indexed document. |
IndexRequest |
type(java.lang.String type)
Sets the type of the indexed document. |
byte[] |
underlyingSource()
|
int |
underlyingSourceLength()
|
int |
underlyingSourceOffset()
|
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)
|
Methods inherited from class org.elasticsearch.action.support.replication.ShardReplicationOperationRequest |
---|
consistencyLevel, index, listenerThreaded, operationThreaded, replicationType, timeout |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IndexRequest()
public IndexRequest(java.lang.String index)
type(String)
,
id(String)
and source(byte[])
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 documentMethod Detail |
---|
public ActionRequestValidationException validate()
validate
in interface ActionRequest
validate
in class ShardReplicationOperationRequest
public void beforeLocalFork()
beforeLocalFork
in class ShardReplicationOperationRequest
public IndexRequest index(java.lang.String index)
index
in class ShardReplicationOperationRequest
public IndexRequest contentType(XContentType contentType)
public IndexRequest listenerThreaded(boolean threadedListener)
listenerThreaded
in interface ActionRequest
listenerThreaded
in class ShardReplicationOperationRequest
public IndexRequest operationThreaded(boolean threadedOperation)
operationThreaded
in class ShardReplicationOperationRequest
public java.lang.String type()
@Required public IndexRequest type(java.lang.String type)
public java.lang.String id()
public IndexRequest id(java.lang.String id)
public IndexRequest routing(java.lang.String routing)
public java.lang.String routing()
public IndexRequest parent(java.lang.String parent)
public java.lang.String parent()
public IndexRequest timestamp(java.lang.String timestamp)
public java.lang.String timestamp()
public IndexRequest ttl(java.lang.Long ttl) throws ElasticSearchGenerationException
ElasticSearchGenerationException
public long ttl()
public byte[] source()
public byte[] underlyingSource()
public int underlyingSourceOffset()
public int underlyingSourceLength()
@Required public IndexRequest source(java.util.Map source) throws ElasticSearchGenerationException
Requests.INDEX_CONTENT_TYPE
.
source
- The map to index
ElasticSearchGenerationException
@Required public IndexRequest source(java.util.Map source, XContentType contentType) throws ElasticSearchGenerationException
source
- The map to index
ElasticSearchGenerationException
@Required public IndexRequest source(java.lang.String source)
Note, its preferable to either set it using source(org.elasticsearch.common.xcontent.XContentBuilder)
or using the source(byte[])
.
@Required public IndexRequest source(XContentBuilder sourceBuilder)
@Required public IndexRequest source(java.lang.String field1, java.lang.Object value1)
@Required public IndexRequest source(java.lang.String field1, java.lang.Object value1, java.lang.String field2, java.lang.Object value2)
@Required public IndexRequest source(java.lang.String field1, java.lang.Object value1, java.lang.String field2, java.lang.Object value2, java.lang.String field3, java.lang.Object value3)
@Required public IndexRequest source(java.lang.String field1, java.lang.Object value1, java.lang.String field2, java.lang.Object value2, java.lang.String field3, java.lang.Object value3, java.lang.String field4, java.lang.Object value4)
public IndexRequest source(byte[] source)
@Required public IndexRequest source(byte[] source, int offset, int length)
source
- The source to indexoffset
- The offset in the byte arraylength
- The length of the data@Required public IndexRequest source(byte[] source, int offset, int length, boolean unsafe)
source
- The source to indexoffset
- The offset in the byte arraylength
- The length of the dataunsafe
- Is the byte array safe to be used form a different threadpublic IndexRequest timeout(TimeValue timeout)
public IndexRequest timeout(java.lang.String timeout)
public IndexRequest opType(IndexRequest.OpType opType)
public IndexRequest opType(java.lang.String opType) throws ElasticSearchIllegalArgumentException
opType(org.elasticsearch.action.index.IndexRequest.OpType)
. Can
be either "index" or "create".
ElasticSearchIllegalArgumentException
public IndexRequest replicationType(ReplicationType replicationType)
replicationType
in class ShardReplicationOperationRequest
public IndexRequest consistencyLevel(WriteConsistencyLevel consistencyLevel)
WriteConsistencyLevel.DEFAULT
consistencyLevel
in class ShardReplicationOperationRequest
public IndexRequest replicationType(java.lang.String replicationType)
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 IndexRequest percolate(java.lang.String percolate)
public java.lang.String percolate()
public void process(MetaData metaData, java.lang.String aliasOrIndex, @Nullable MappingMetaData mappingMd, boolean allowIdGeneration) throws ElasticSearchException
ElasticSearchException
public void readFrom(StreamInput in) throws java.io.IOException
readFrom
in interface Streamable
readFrom
in class ShardReplicationOperationRequest
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
writeTo
in interface Streamable
writeTo
in class ShardReplicationOperationRequest
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |