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
,Writeable
,ToXContent
,ToXContentObject
,TaskAwareRequest
public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> implements IndicesRequest, ToXContentObject
A request to create an index. Best created with
Requests.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
-
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.CreateIndexRequest(StreamInput in)
-
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<java.lang.String,?> 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<java.lang.String,?> 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()
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<java.lang.String,?> 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)
ActionRequestValidationException
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 into the 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.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.tasks.TaskAwareRequest
createTask, getDescription, setParentTask
-
Field Details
-
Constructor Details
-
CreateIndexRequest
- Throws:
java.io.IOException
-
CreateIndexRequest
public CreateIndexRequest() -
CreateIndexRequest
public CreateIndexRequest(java.lang.String index)Constructs a new request to create an index with the specified name. -
CreateIndexRequest
Constructs a new request to create an index with the specified name and settings.
-
-
Method Details
-
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
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
-
settings
The settings to create the index with. -
cause
public java.lang.String cause()The cause for this index creation. -
settings
The settings to create the index with. -
settings
The settings to create the index with. -
settings
The settings to create the index with (either json or yaml format) -
settings
Allows to set the settings using a json builder. -
settings
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
The cause for this index creation. -
mapping
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<java.lang.String,?> source)Adds mapping that will be added when the index gets created.- Parameters:
type
- The mapping typesource
- The mapping source
-
mapping
A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true"). -
aliases
Sets the aliases that will be associated with the index when it gets created -
aliases
Sets the aliases that will be associated with the index when it gets created -
aliases
Sets the aliases that will be associated with the index when it gets created -
aliases
Sets the aliases that will be associated with the index when it gets created -
alias
Adds an alias that will be associated with the index when it gets created -
source
Sets the settings and mappings as a single source. -
source
Sets the settings and mappings as a single source. -
source
Sets the settings and mappings as a single source. -
source
Sets the settings and mappings as a single source. -
source
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
-
waitForActiveShards
-
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
A shortcut forwaitForActiveShards(ActiveShardCount)
where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)
to get the ActiveShardCount. -
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- 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
-