---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Create index with mappings:
- do:
    indices.create:
      index: "test_index"
      body:
        mappings: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_mapping:
      index: "test_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- is_true: "test_index.mappings"
---
Create index with settings:
- do:
    indices.create:
      index: "test_index"
      body:
        settings:
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_settings:
      index: "test_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test_index.settings.index.number_of_replicas: "0"
---
Create index:
- do:
    indices.create:
      index: "test_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    acknowledged: true
- match:
    index: "test_index"
---
Create index with wait_for_active_shards set to all:
- do:
    indices.create:
      index: "test_index"
      wait_for_active_shards: "all"
      body:
        settings:
          number_of_replicas: "0"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    acknowledged: true
- match:
    shards_acknowledged: true
---
Create index with aliases:
- do:
    indices.create:
      index: "test_index"
      body:
        mappings:
          properties:
            field:
              type: "text"
        aliases:
          test_alias: {}
          test_blias:
            routing: "b"
          test_clias:
            filter:
              term:
                field: "value"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_alias:
      index: "test_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test_index.aliases.test_blias.search_routing: "b"
- match:
    test_index.aliases.test_blias.index_routing: "b"
- is_false: "test_index.aliases.test_blias.filter"
- match:
    test_index.aliases.test_clias.filter.term.field: "value"
- is_false: "test_index.aliases.test_clias.index_routing"
- is_false: "test_index.aliases.test_clias.search_routing"
---
Create index with write aliases:
- do:
    indices.create:
      index: "test_index"
      body:
        aliases:
          test_alias: {}
          test_blias:
            is_write_index: false
          test_clias:
            is_write_index: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_alias:
      index: "test_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- is_false: "test_index.aliases.test_alias.is_write_index"
- is_false: "test_index.aliases.test_blias.is_write_index"
- is_true: "test_index.aliases.test_clias.is_write_index"
---
Create index with invalid mappings:
- do:
    catch: "/illegal_argument_exception/"
    indices.create:
      index: "test_index"
      body:
        mappings:
          properties:
            ? ""
            : type: "keyword"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
Create index without soft deletes:
- requires:
    cluster_features:
    - "gte_v8.0.0"
    reason: "indices without soft-deletes is no longer supported "
- do:
    catch: "/illegal_argument_exception/"
    indices.create:
      index: "test_index"
      body:
        settings:
          soft_deletes.enabled: false
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
Create with alias containing date math:
- requires:
    cluster_features:
    - "gte_v7.13.0"
    reason: "date math support for aliases was added in 7.13"
- do:
    indices.create:
      index: "<logs_http_{2022-12-31||/d{yyyy-MM-dd}}>"
      body:
        aliases:
          <logs_{2022-12-31||/d{yyyy-MM-dd}}>: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.exists_alias:
      name: "logs_2022-12-31"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- is_true: ""
---
Create lookup index:
- requires:
    test_runner_features:
    - "capabilities"
    - "default_shards"
    capabilities:
    - method: "PUT"
      path: "/{index}"
      capabilities:
      - "lookup_index_mode"
    reason: "Support for 'lookup' index mode capability required"
- do:
    indices.create:
      index: "test_lookup"
      body:
        settings:
          index.mode: "lookup"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_settings:
      index: "test_lookup"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test_lookup.settings.index.number_of_shards: "1"
---
Create lookup index with one shard:
- requires:
    test_runner_features:
    - "capabilities"
    - "default_shards"
    capabilities:
    - method: "PUT"
      path: "/{index}"
      capabilities:
      - "lookup_index_mode"
    reason: "Support for 'lookup' index mode capability required"
- do:
    indices.create:
      index: "test_lookup"
      body:
        settings:
          index:
            mode: "lookup"
            number_of_shards: 1
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.get_settings:
      index: "test_lookup"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    test_lookup.settings.index.number_of_shards: "1"
---
Create lookup index with two shards:
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "PUT"
      path: "/{index}"
      capabilities:
      - "lookup_index_mode"
    reason: "Support for 'lookup' index mode capability required"
- do:
    catch: "/illegal_argument_exception/"
    indices.create:
      index: "test_lookup"
      body:
        settings:
          index.mode: "lookup"
          index.number_of_shards: 2
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
Create index with invalid field type:
- requires:
    cluster_features:
    - "mapper.unknown_field_mapping_update_error_message"
    reason: "Update error message for unknown field type"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        mappings:
          properties:
            content:
              type: "invalid"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    error.type: "mapper_parsing_exception"
- match:
    error.reason: "Failed to parse mapping: The mapper type [invalid] declared on\
      \ field [content] does not exist. It might have been created within a future\
      \ version or requires a plugin to be installed. Check the documentation."
---
Create index with invalid runtime field type:
- requires:
    cluster_features:
    - "mapper.unknown_field_mapping_update_error_message"
    reason: "Update error message for unknown field type"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        mappings:
          runtime:
            content:
              type: "invalid"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    error.type: "mapper_parsing_exception"
- match:
    error.reason: "Failed to parse mapping: The mapper type [invalid] declared on\
      \ runtime field [content] does not exist. It might have been created within\
      \ a future version or requires a plugin to be installed. Check the documentation."
---
Create index with invalid multi-field type:
- requires:
    cluster_features:
    - "mapper.unknown_field_mapping_update_error_message"
    reason: "Update error message for unknown field type"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        mappings:
          properties:
            city:
              type: "text"
              fields:
                raw:
                  type: "invalid"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    error.type: "mapper_parsing_exception"
- match:
    error.reason: "Failed to parse mapping: The mapper type [invalid] declared on\
      \ field [raw] does not exist. It might have been created within a future version\
      \ or requires a plugin to be installed. Check the documentation."
---
Poorly formatted request returns bad_request:
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "PUT"
      path: "/{index}"
      capabilities:
      - "poorly_formatted_bad_request"
    reason: "requires poorly_formatted_bad_request bug fix"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        mappings: "bad mappings"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        mappings:
          properties: "bad properties"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        settings: "bad settings"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    catch: "bad_request"
    indices.create:
      index: "test_index"
      body:
        aliases: "bad alias"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
Create index with hunspell missing dict:
- requires:
    test_runner_features:
    - "capabilities"
    capabilities:
    - method: "PUT"
      path: "/{index}"
      capabilities:
      - "hunspell_dict_400"
    reason: "bugfix 'hunspell_dict_400' capability required"
- do:
    catch: "bad_request"
    indices.create:
      index: "bad_hunspell_index"
      body:
        settings:
          analysis:
            analyzer:
              en:
                tokenizer: "standard"
                filter:
                - "my_en_US_dict_stemmer"
              filter:
                my_en_US_dict_stemmer: null
                type: "hunspell"
                locale: "en_US"
                dedup: false
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
