Class CreateIndexRequest

java.lang.Object
org.elasticsearch.client.TimedRequest
org.elasticsearch.client.indices.CreateIndexRequest
All Implemented Interfaces:
Validatable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public class CreateIndexRequest extends TimedRequest implements Validatable, org.elasticsearch.xcontent.ToXContentObject
A request to create an index.
  • Constructor Details

    • CreateIndexRequest

      public CreateIndexRequest(String index)
      Constructs a new request to create an index with the specified name.
  • Method Details

    • index

      public String index()
      The name of the index to create.
    • settings

      public Settings settings()
      The settings to create the index with.
    • 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.xcontent.XContentType xContentType)
      The settings to create the index with (either json or yaml format)
    • settings

      public CreateIndexRequest settings(org.elasticsearch.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)
    • mappings

      public BytesReference mappings()
    • mappingsXContentType

      public org.elasticsearch.xcontent.XContentType mappingsXContentType()
    • mapping

      public CreateIndexRequest mapping(String source, org.elasticsearch.xcontent.XContentType xContentType)
      Adds mapping that will be added when the index gets created. Note that the definition should *not* be nested under a type name.
      Parameters:
      source - The mapping source
      xContentType - The content type of the source
    • mapping

      public CreateIndexRequest mapping(org.elasticsearch.xcontent.XContentBuilder source)
      Adds mapping that will be added when the index gets created. Note that the definition should *not* be nested under a type name.
      Parameters:
      source - The mapping source
    • mapping

      public CreateIndexRequest mapping(Map<String,?> source)
      Adds mapping that will be added when the index gets created. Note that the definition should *not* be nested under a type name.
      Parameters:
      source - The mapping source
    • mapping

      public CreateIndexRequest mapping(BytesReference source, org.elasticsearch.xcontent.XContentType xContentType)
      Adds mapping that will be added when the index gets created. Note that the definition should *not* be nested under a type name.
      Parameters:
      source - The mapping source
      xContentType - the content type of the mapping source
    • aliases

      public Set<Alias> aliases()
    • 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.xcontent.XContentBuilder source)
      Sets the aliases that will be associated with the index when it gets created
    • aliases

      public CreateIndexRequest aliases(String source, org.elasticsearch.xcontent.XContentType contentType)
      Sets the aliases that will be associated with the index when it gets created
    • aliases

      public CreateIndexRequest aliases(BytesReference source, org.elasticsearch.xcontent.XContentType contentType)
      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
    • aliases

      public CreateIndexRequest aliases(Collection<Alias> aliases)
      Adds aliases 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. Note that the mapping definition should *not* be nested under a type name.
    • source

      public CreateIndexRequest source(org.elasticsearch.xcontent.XContentBuilder source)
      Sets the settings and mappings as a single source. Note that the mapping definition should *not* be nested under a type name.
    • source

      public CreateIndexRequest source(BytesReference source, org.elasticsearch.xcontent.XContentType xContentType)
      Sets the settings and mappings as a single source. Note that the mapping definition should *not* be nested under a type name.
    • source

      public CreateIndexRequest source(Map<String,?> source)
      Sets the settings and mappings as a single source. Note that the mapping definition should *not* be nested under a type name.
    • 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
    • toXContent

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

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