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.EmptyNested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.ReplaceableNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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 ParseFieldALIASESstatic ParseFieldMAPPINGSstatic ParseFieldSETTINGSFields inherited from class org.elasticsearch.action.support.master.AcknowledgedRequest
DEFAULT_ACK_TIMEOUT, timeoutFields 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 CreateIndexRequestalias(Alias alias)Adds an alias that will be associated with the index when it gets createdjava.util.Set<Alias>aliases()CreateIndexRequestaliases(java.lang.String source)Sets the aliases that will be associated with the index when it gets createdCreateIndexRequestaliases(java.util.Map<java.lang.String,?> source)Sets the aliases that will be associated with the index when it gets createdCreateIndexRequestaliases(BytesReference source)Sets the aliases that will be associated with the index when it gets createdCreateIndexRequestaliases(XContentBuilder source)Sets the aliases that will be associated with the index when it gets createdjava.lang.Stringcause()The cause for this index creation.CreateIndexRequestcause(java.lang.String cause)The cause for this index creation.java.lang.Stringindex()The index name to create.CreateIndexRequestindex(java.lang.String index)java.lang.String[]indices()Returns the array of indices that the action relates toIndicesOptionsindicesOptions()Returns the indices options used to resolve indices.XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params)CreateIndexRequestmapping(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").CreateIndexRequestmapping(java.lang.String type, java.lang.String source, XContentType xContentType)Adds mapping that will be added when the index gets created.CreateIndexRequestmapping(java.lang.String type, java.util.Map<java.lang.String,?> source)Adds mapping that will be added when the index gets created.CreateIndexRequestmapping(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()Settingssettings()The settings to create the index with.CreateIndexRequestsettings(java.lang.String source, XContentType xContentType)The settings to create the index with (either json or yaml format)CreateIndexRequestsettings(java.util.Map<java.lang.String,?> source)The settings to create the index with (either json/yaml/properties format)CreateIndexRequestsettings(Settings settings)The settings to create the index with.CreateIndexRequestsettings(Settings.Builder settings)The settings to create the index with.CreateIndexRequestsettings(XContentBuilder builder)Allows to set the settings using a json builder.CreateIndexRequestsource(byte[] source, int offset, int length, XContentType xContentType)Sets the settings and mappings as a single source.CreateIndexRequestsource(byte[] source, XContentType xContentType)Sets the settings and mappings as a single source.CreateIndexRequestsource(java.lang.String source, XContentType xContentType)Sets the settings and mappings as a single source.CreateIndexRequestsource(java.util.Map<java.lang.String,?> source, DeprecationHandler deprecationHandler)Sets the settings and mappings as a single source.CreateIndexRequestsource(BytesReference source, XContentType xContentType)Sets the settings and mappings as a single source.CreateIndexRequestsource(XContentBuilder source)Sets the settings and mappings as a single source.XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)ActionRequestValidationExceptionvalidate()ActiveShardCountwaitForActiveShards()CreateIndexRequestwaitForActiveShards(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.CreateIndexRequestwaitForActiveShards(ActiveShardCount waitForActiveShards)Sets the number of shard copies that should be active for index creation to return.voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.support.master.AcknowledgedRequest
ackTimeout, timeout, timeout, timeoutMethods inherited from class org.elasticsearch.action.support.master.MasterNodeRequest
masterNodeTimeout, masterNodeTimeout, masterNodeTimeoutMethods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTaskMethods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
validatein classActionRequest
-
indices
public java.lang.String[] indices()Description copied from interface:IndicesRequestReturns the array of indices that the action relates to- Specified by:
indicesin interfaceIndicesRequest
-
indicesOptions
Description copied from interface:IndicesRequestReturns 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:
indicesOptionsin 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.ALLto 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:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classAcknowledgedRequest<CreateIndexRequest>- Throws:
java.io.IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceToXContent- Throws:
java.io.IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException- Throws:
java.io.IOException
-