Class CreateIndexRequest
- java.lang.Object
-
- org.elasticsearch.transport.TransportMessage
-
- org.elasticsearch.transport.TransportRequest
-
- org.elasticsearch.action.ActionRequest
-
- org.elasticsearch.action.support.master.MasterNodeRequest<Request>
-
- org.elasticsearch.action.support.master.AcknowledgedRequest<CreateIndexRequest>
-
- org.elasticsearch.action.admin.indices.create.CreateIndexRequest
-
- All Implemented Interfaces:
IndicesRequest
,AckedRequest
,Streamable
,Writeable
,ToXContent
,ToXContentObject
,TaskAwareRequest
public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> implements IndicesRequest, ToXContentObject
A request to create an index. Best created withRequests.createIndexRequest(String)
.The index created can optionally be created with
settings(org.elasticsearch.common.settings.Settings)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
-
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.Replaceable
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static ParseField
ALIASES
static ParseField
MAPPINGS
static ParseField
SETTINGS
-
Fields inherited from class org.elasticsearch.action.support.master.AcknowledgedRequest
DEFAULT_ACK_TIMEOUT, timeout
-
Fields inherited from class org.elasticsearch.action.support.master.MasterNodeRequest
DEFAULT_MASTER_NODE_TIMEOUT, masterNodeTimeout
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description CreateIndexRequest()
CreateIndexRequest(java.lang.String index)
Constructs a new request to create an index with the specified name.CreateIndexRequest(java.lang.String index, Settings settings)
Constructs a new request to create an index with the specified name and settings.
-
Method Summary
Modifier and Type Method Description CreateIndexRequest
alias(Alias alias)
Adds an alias that will be associated with the index when it gets createdjava.util.Set<Alias>
aliases()
CreateIndexRequest
aliases(java.lang.String source)
Sets the aliases that will be associated with the index when it gets createdCreateIndexRequest
aliases(java.util.Map source)
Sets the aliases that will be associated with the index when it gets createdCreateIndexRequest
aliases(BytesReference source)
Sets the aliases that will be associated with the index when it gets createdCreateIndexRequest
aliases(XContentBuilder source)
Sets the aliases that will be associated with the index when it gets createdjava.lang.String
cause()
The cause for this index creation.CreateIndexRequest
cause(java.lang.String cause)
The cause for this index creation.java.lang.String
index()
The index name to create.CreateIndexRequest
index(java.lang.String index)
java.lang.String[]
indices()
Returns the array of indices that the action relates toIndicesOptions
indicesOptions()
Returns the indices options used to resolve indices.XContentBuilder
innerToXContent(XContentBuilder builder, ToXContent.Params params)
CreateIndexRequest
mapping(java.lang.String type, java.lang.Object... source)
A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true").CreateIndexRequest
mapping(java.lang.String type, java.lang.String source, XContentType xContentType)
Adds mapping that will be added when the index gets created.CreateIndexRequest
mapping(java.lang.String type, java.util.Map source)
Adds mapping that will be added when the index gets created.CreateIndexRequest
mapping(java.lang.String type, XContentBuilder source)
Adds mapping that will be added when the index gets created.java.util.Map<java.lang.String,java.lang.String>
mappings()
void
readFrom(StreamInput in)
Set this object's fields from a StreamInput.Settings
settings()
The settings to create the index with.CreateIndexRequest
settings(java.lang.String source, XContentType xContentType)
The settings to create the index with (either json or yaml format)CreateIndexRequest
settings(java.util.Map source)
The settings to create the index with (either json/yaml/properties format)CreateIndexRequest
settings(Settings settings)
The settings to create the index with.CreateIndexRequest
settings(Settings.Builder settings)
The settings to create the index with.CreateIndexRequest
settings(XContentBuilder builder)
Allows to set the settings using a json builder.CreateIndexRequest
source(byte[] source, int offset, int length, XContentType xContentType)
Sets the settings and mappings as a single source.CreateIndexRequest
source(byte[] source, XContentType xContentType)
Sets the settings and mappings as a single source.CreateIndexRequest
source(java.lang.String source, XContentType xContentType)
Sets the settings and mappings as a single source.CreateIndexRequest
source(java.util.Map<java.lang.String,?> source, DeprecationHandler deprecationHandler)
Sets the settings and mappings as a single source.CreateIndexRequest
source(BytesReference source, XContentType xContentType)
Sets the settings and mappings as a single source.CreateIndexRequest
source(XContentBuilder source)
Sets the settings and mappings as a single source.XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
boolean
updateAllTypes()
True if all fields that span multiple types should be updated, false otherwiseCreateIndexRequest
updateAllTypes(boolean updateAllTypes)
Deprecated.useless with 6.x indices which may only have one typeActionRequestValidationException
validate()
ActiveShardCount
waitForActiveShards()
CreateIndexRequest
waitForActiveShards(int waitForActiveShards)
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount.CreateIndexRequest
waitForActiveShards(ActiveShardCount waitForActiveShards)
Sets the number of shard copies that should be active for index creation to return.void
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.-
Methods inherited from class org.elasticsearch.action.support.master.AcknowledgedRequest
ackTimeout, timeout, timeout, timeout
-
Methods inherited from class org.elasticsearch.action.support.master.MasterNodeRequest
masterNodeTimeout, masterNodeTimeout, masterNodeTimeout
-
Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
-
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
-
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.cluster.ack.AckedRequest
masterNodeTimeout
-
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, getDescription, setParentTask
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
MAPPINGS
public static final ParseField MAPPINGS
-
SETTINGS
public static final ParseField SETTINGS
-
ALIASES
public static final ParseField ALIASES
-
-
Constructor Detail
-
CreateIndexRequest
public CreateIndexRequest()
-
CreateIndexRequest
public CreateIndexRequest(java.lang.String index)
Constructs a new request to create an index with the specified name.
-
CreateIndexRequest
public CreateIndexRequest(java.lang.String index, Settings settings)
Constructs a new request to create an index with the specified name and settings.
-
-
Method Detail
-
validate
public ActionRequestValidationException validate()
- Specified by:
validate
in classActionRequest
-
indices
public java.lang.String[] indices()
Description copied from interface:IndicesRequest
Returns the array of indices that the action relates to- Specified by:
indices
in interfaceIndicesRequest
-
indicesOptions
public IndicesOptions indicesOptions()
Description copied from interface:IndicesRequest
Returns the indices options used to resolve indices. They tell for instance whether a single index is accepted, whether an empty array will be converted to _all, and how wildcards will be expanded if needed.- Specified by:
indicesOptions
in interfaceIndicesRequest
-
index
public java.lang.String index()
The index name to create.
-
index
public CreateIndexRequest index(java.lang.String index)
-
settings
public Settings settings()
The settings to create the index with.
-
cause
public java.lang.String cause()
The cause for this index creation.
-
settings
public CreateIndexRequest settings(Settings.Builder settings)
The settings to create the index with.
-
settings
public CreateIndexRequest settings(Settings settings)
The settings to create the index with.
-
settings
public CreateIndexRequest settings(java.lang.String source, XContentType xContentType)
The settings to create the index with (either json or yaml format)
-
settings
public CreateIndexRequest settings(XContentBuilder builder)
Allows to set the settings using a json builder.
-
settings
public CreateIndexRequest settings(java.util.Map source)
The settings to create the index with (either json/yaml/properties format)
-
mapping
public CreateIndexRequest mapping(java.lang.String type, java.lang.String source, XContentType xContentType)
Adds mapping that will be added when the index gets created.- Parameters:
type
- The mapping typesource
- The mapping sourcexContentType
- The content type of the source
-
cause
public CreateIndexRequest cause(java.lang.String cause)
The cause for this index creation.
-
mapping
public CreateIndexRequest mapping(java.lang.String type, XContentBuilder source)
Adds mapping that will be added when the index gets created.- Parameters:
type
- The mapping typesource
- The mapping source
-
mapping
public CreateIndexRequest mapping(java.lang.String type, java.util.Map source)
Adds mapping that will be added when the index gets created.- Parameters:
type
- The mapping typesource
- The mapping source
-
mapping
public CreateIndexRequest mapping(java.lang.String type, java.lang.Object... source)
A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true").
-
aliases
public CreateIndexRequest aliases(java.util.Map source)
Sets the aliases that will be associated with the index when it gets created
-
aliases
public CreateIndexRequest aliases(XContentBuilder source)
Sets the aliases that will be associated with the index when it gets created
-
aliases
public CreateIndexRequest aliases(java.lang.String source)
Sets the aliases that will be associated with the index when it gets created
-
aliases
public CreateIndexRequest aliases(BytesReference source)
Sets the aliases that will be associated with the index when it gets created
-
alias
public CreateIndexRequest alias(Alias alias)
Adds an alias that will be associated with the index when it gets created
-
source
public CreateIndexRequest source(java.lang.String source, XContentType xContentType)
Sets the settings and mappings as a single source.
-
source
public CreateIndexRequest source(XContentBuilder source)
Sets the settings and mappings as a single source.
-
source
public CreateIndexRequest source(byte[] source, XContentType xContentType)
Sets the settings and mappings as a single source.
-
source
public CreateIndexRequest source(byte[] source, int offset, int length, XContentType xContentType)
Sets the settings and mappings as a single source.
-
source
public CreateIndexRequest source(BytesReference source, XContentType xContentType)
Sets the settings and mappings as a single source.
-
source
public CreateIndexRequest source(java.util.Map<java.lang.String,?> source, DeprecationHandler deprecationHandler)
Sets the settings and mappings as a single source.
-
mappings
public java.util.Map<java.lang.String,java.lang.String> mappings()
-
aliases
public java.util.Set<Alias> aliases()
-
updateAllTypes
public boolean updateAllTypes()
True if all fields that span multiple types should be updated, false otherwise
-
updateAllTypes
@Deprecated public CreateIndexRequest updateAllTypes(boolean updateAllTypes)
Deprecated.useless with 6.x indices which may only have one typeSeeupdateAllTypes()
-
waitForActiveShards
public ActiveShardCount waitForActiveShards()
-
waitForActiveShards
public CreateIndexRequest waitForActiveShards(ActiveShardCount waitForActiveShards)
Sets the number of shard copies that should be active for index creation to return. Defaults toActiveShardCount.DEFAULT
, which will wait for one shard copy (the primary) to become active. Set this value toActiveShardCount.ALL
to wait for all shards (primary and all replicas) to be active before returning. Otherwise, useActiveShardCount.from(int)
to set this value to any non-negative integer, up to the number of copies per shard (number of replicas + 1), to wait for the desired amount of shard copies to become active before returning. Index creation will only wait up until the timeout value for the number of shard copies to be active before returning. CheckShardsAcknowledgedResponse.isShardsAcknowledged()
to determine if the requisite shard copies were all started before returning or timing out.- Parameters:
waitForActiveShards
- number of active shard copies to wait on
-
waitForActiveShards
public CreateIndexRequest waitForActiveShards(int waitForActiveShards)
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount.
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in interfaceStreamable
- Overrides:
readFrom
in classAcknowledgedRequest<CreateIndexRequest>
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in interfaceStreamable
- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classAcknowledgedRequest<CreateIndexRequest>
- Throws:
java.io.IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
-