Class CreateIndexRequest

All Implemented Interfaces:
IndicesRequest, AckedRequest, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, org.elasticsearch.core.RefCounted, TaskAwareRequest

public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> implements IndicesRequest, org.elasticsearch.common.xcontent.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).

See Also:
IndicesAdminClient.create(CreateIndexRequest), Requests.createIndexRequest(String), CreateIndexResponse
  • Field Details

    • MAPPINGS

      public static final org.elasticsearch.common.xcontent.ParseField MAPPINGS
    • SETTINGS

      public static final org.elasticsearch.common.xcontent.ParseField SETTINGS
    • ALIASES

      public static final org.elasticsearch.common.xcontent.ParseField ALIASES
  • Constructor Details

    • CreateIndexRequest

      public CreateIndexRequest(StreamInput in) throws IOException
      Constructs a new request by deserializing an input
      Parameters:
      in - the input from which to deserialize
      Throws:
      IOException
    • CreateIndexRequest

      public CreateIndexRequest()
    • CreateIndexRequest

      public CreateIndexRequest(String index)
      Constructs a request to create an index.
      Parameters:
      index - the name of the index
    • CreateIndexRequest

      public CreateIndexRequest(String index, Settings settings)
      Constructs a request to create an index.
      Parameters:
      index - the name of the index
      settings - the settings to apply to the index
  • Method Details

    • validate

      Specified by:
      validate in class ActionRequest
    • indices

      public String[] indices()
      Description copied from interface: IndicesRequest
      Returns the array of indices that the action relates to
      Specified by:
      indices in interface IndicesRequest
    • 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 interface IndicesRequest
    • index

      public String index()
      The index name to create.
    • index

      public CreateIndexRequest index(String index)
    • settings

      public Settings settings()
      The settings to create the index with.
    • cause

      public String cause()
      The cause for this index creation.
    • origin

      public String origin()
    • origin

      public CreateIndexRequest origin(String origin)
    • 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(String source, org.elasticsearch.common.xcontent.XContentType xContentType)
      The settings to create the index with (either json or yaml format)
    • settings

      public CreateIndexRequest settings(org.elasticsearch.common.xcontent.XContentBuilder builder)
      Allows to set the settings using a json builder.
    • settings

      public CreateIndexRequest settings(Map<String,?> source)
      The settings to create the index with (either json/yaml/properties format)
    • mapping

      public CreateIndexRequest mapping(String type, String source, org.elasticsearch.common.xcontent.XContentType xContentType)
      Adds mapping that will be added when the index gets created.
      Parameters:
      type - The mapping type
      source - The mapping source
      xContentType - The content type of the source
    • cause

      public CreateIndexRequest cause(String cause)
      The cause for this index creation.
    • mapping

      public CreateIndexRequest mapping(String type, org.elasticsearch.common.xcontent.XContentBuilder source)
      Adds mapping that will be added when the index gets created.
      Parameters:
      type - The mapping type
      source - The mapping source
    • mapping

      public CreateIndexRequest mapping(String type, Map<String,?> source)
      Adds mapping that will be added when the index gets created.
      Parameters:
      type - The mapping type
      source - The mapping source
    • mapping

      public CreateIndexRequest mapping(String type, Object... source)
      A specialized simplified mapping source method, takes the form of simple properties definition: ("field1", "type=string,store=true").
    • aliases

      public CreateIndexRequest aliases(Map<String,?> source)
      Sets the aliases that will be associated with the index when it gets created
    • aliases

      public CreateIndexRequest aliases(org.elasticsearch.common.xcontent.XContentBuilder source)
      Sets the aliases that will be associated with the index when it gets created
    • aliases

      public CreateIndexRequest aliases(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(String source, org.elasticsearch.common.xcontent.XContentType xContentType)
      Sets the settings and mappings as a single source.
    • source

      public CreateIndexRequest source(org.elasticsearch.common.xcontent.XContentBuilder source)
      Sets the settings and mappings as a single source.
    • source

      public CreateIndexRequest source(byte[] source, org.elasticsearch.common.xcontent.XContentType xContentType)
      Sets the settings and mappings as a single source.
    • source

      public CreateIndexRequest source(byte[] source, int offset, int length, org.elasticsearch.common.xcontent.XContentType xContentType)
      Sets the settings and mappings as a single source.
    • source

      public CreateIndexRequest source(BytesReference source, org.elasticsearch.common.xcontent.XContentType xContentType)
      Sets the settings and mappings as a single source.
    • source

      public CreateIndexRequest source(Map<String,?> source, org.elasticsearch.common.xcontent.DeprecationHandler deprecationHandler)
      Sets the settings and mappings as a single source.
    • mappings

      public Map<String,String> mappings()
    • aliases

      public 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 to ActiveShardCount.DEFAULT, which will wait for one shard copy (the primary) to become active. Set this value to ActiveShardCount.ALL to wait for all shards (primary and all replicas) to be active before returning. Otherwise, use ActiveShardCount.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. Check ShardsAcknowledgedResponse.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 for waitForActiveShards(ActiveShardCount) where the numerical shard count is passed in, instead of having to first call ActiveShardCount.from(int) to get the ActiveShardCount.
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class AcknowledgedRequest<CreateIndexRequest>
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      IOException
    • innerToXContent

      public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object