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 ParseFieldALIASESstatic ParseFieldMAPPINGSstatic ParseFieldSETTINGS-
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 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()voidreadFrom(StreamInput in)Set this object's fields from a StreamInput.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 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:
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
public IndicesOptions 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
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<java.lang.String,?> 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<java.lang.String,?> 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<java.lang.String,?> 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()
-
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.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
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:StreamableSet this object's fields from a StreamInput.- Specified by:
readFromin interfaceStreamable- Overrides:
readFromin classAcknowledgedRequest<CreateIndexRequest>- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:StreamableWrite this object's fields to a StreamOutput.- Specified by:
writeToin interfaceStreamable- 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
-
-