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
,org.elasticsearch.core.RefCounted
,TaskAwareRequest
public class CreateIndexRequest
extends AcknowledgedRequest<CreateIndexRequest>
implements IndicesRequest
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.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.elasticsearch.xcontent.ParseField
static final org.elasticsearch.xcontent.ParseField
static final org.elasticsearch.xcontent.ParseField
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
ConstructorDescriptionCreateIndexRequest
(String index) Constructs a request to create an index.CreateIndexRequest
(String index, Settings settings) Constructs a request to create an index.Constructs a new request by deserializing an input -
Method Summary
Modifier and TypeMethodDescriptionAdds an alias that will be associated with the index when it gets createdaliases()
Sets the aliases that will be associated with the index when it gets createdSets the aliases that will be associated with the index when it gets createdaliases
(BytesReference source) Sets the aliases that will be associated with the index when it gets createdaliases
(org.elasticsearch.xcontent.XContentBuilder source) Sets the aliases that will be associated with the index when it gets createdcause()
The cause for this index creation.The cause for this index creation.boolean
int
hashCode()
index()
The index name to create.String[]
indices()
Returns the array of indices that the action relates toReturns the indices options used to resolve indices.Set the mapping for this index The mapping should be in the form of a JSON string, with an outer _doc keySet the mapping for this indexmapping
(org.elasticsearch.xcontent.XContentBuilder source) Set the mapping for this indexmappings()
origin()
settings()
The settings to create the index with.The settings to create the index with (either json or yaml format)The settings to create the index with (either json/yaml/properties format)The settings to create the index with.settings
(Settings.Builder settings) The settings to create the index with.settings
(org.elasticsearch.xcontent.XContentBuilder builder) Allows to set the settings using a json builder.simpleMapping
(String... source) A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true").source
(byte[] source, int offset, int length, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source.source
(byte[] source, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source.Sets the settings and mappings as a single source.Sets the settings and mappings as a single source.source
(BytesReference source, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source.source
(org.elasticsearch.xcontent.XContentBuilder source) Sets the settings and mappings as a single source.validate()
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.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.action.ActionRequest
getShouldStoreResult
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask, toString
Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRef
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.cluster.ack.AckedRequest
masterNodeTimeout
Methods inherited from interface org.elasticsearch.action.IndicesRequest
includeDataStreams
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, getDescription, setParentTask
-
Field Details
-
MAPPINGS
public static final org.elasticsearch.xcontent.ParseField MAPPINGS -
SETTINGS
public static final org.elasticsearch.xcontent.ParseField SETTINGS -
ALIASES
public static final org.elasticsearch.xcontent.ParseField ALIASES
-
-
Constructor Details
-
CreateIndexRequest
Constructs a new request by deserializing an input- Parameters:
in
- the input from which to deserialize- Throws:
IOException
-
CreateIndexRequest
public CreateIndexRequest() -
CreateIndexRequest
Constructs a request to create an index.- Parameters:
index
- the name of the index
-
CreateIndexRequest
Constructs a request to create an index.- Parameters:
index
- the name of the indexsettings
- the settings to apply to the index
-
-
Method Details
-
validate
- Specified by:
validate
in classActionRequest
-
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
The index name to create. -
index
-
settings
The settings to create the index with. -
cause
The cause for this index creation. -
origin
-
origin
-
settings
The settings to create the index with. -
settings
The settings to create the index with. -
settings
public CreateIndexRequest settings(String source, org.elasticsearch.xcontent.XContentType xContentType) 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
Set the mapping for this index The mapping should be in the form of a JSON string, with an outer _doc key.mapping("{\"_doc\":{\"properties\": ... }}")
-
mapping
Set the mapping for this index- Parameters:
source
- The mapping source
-
mapping
Set the mapping for this index- Parameters:
source
- The mapping source
-
simpleMapping
A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true"). -
cause
The cause for this index creation. -
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
public CreateIndexRequest source(String source, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source. -
source
Sets the settings and mappings as a single source. -
source
public CreateIndexRequest source(byte[] source, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source. -
source
public CreateIndexRequest source(byte[] source, int offset, int length, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source. -
source
public CreateIndexRequest source(BytesReference source, org.elasticsearch.xcontent.XContentType xContentType) Sets the settings and mappings as a single source. -
source
public CreateIndexRequest source(Map<String, ?> source, org.elasticsearch.xcontent.DeprecationHandler deprecationHandler) Sets the settings and mappings as a single source. -
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:
IOException
-
equals
-
hashCode
public int hashCode()
-