---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Array of objects:
- do:
    bulk:
      refresh: true
      body:
      - index:
          _index: "test_index"
          _id: "test_id"
      - f1: "v1"
        f2: 42
      - index:
          _index: "test_index"
          _id: "test_id2"
      - f1: "v2"
        f2: 47
    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:
    count:
      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:
    count: 2
---
Empty _id:
- do:
    bulk:
      refresh: true
      body:
      - index:
          _index: "test"
          _id: ""
      - f: 1
      - index:
          _index: "test"
          _id: "id"
      - f: 2
      - index:
          _index: "test"
      - f: 3
    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:
    errors: true
- match:
    items.0.index.status: 400
- match:
    items.0.index.error.type: "illegal_argument_exception"
- match:
    items.0.index.error.reason: "if _id is specified it must not be empty"
- match:
    items.1.index.result: "created"
- match:
    items.2.index.result: "created"
- do:
    count:
      index: "test"
    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:
    count: 2
---
Empty _id with op_type create:
- requires:
    cluster_features:
    - "gte_v7.5.0"
    reason: "auto id + op type create only supported since 7.5"
- do:
    bulk:
      refresh: true
      body:
      - index:
          _index: "test"
          _id: ""
      - f: 1
      - index:
          _index: "test"
          _id: "id"
      - f: 2
      - index:
          _index: "test"
      - f: 3
      - create:
          _index: "test"
      - f: 4
      - index:
          _index: "test"
          op_type: "create"
      - f: 5
    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:
    errors: true
- match:
    items.0.index.status: 400
- match:
    items.0.index.error.type: "illegal_argument_exception"
- match:
    items.0.index.error.reason: "if _id is specified it must not be empty"
- match:
    items.1.index.result: "created"
- match:
    items.2.index.result: "created"
- match:
    items.3.create.result: "created"
- match:
    items.4.create.result: "created"
- do:
    count:
      index: "test"
    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:
    count: 4
---
empty action:
- skip:
    features: "headers"
- do:
    catch: "/Malformed action\\/metadata line \\[3\\], expected FIELD_NAME but found\
      \ \\[END_OBJECT\\]/"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    bulk:
      body: "{\"index\": {\"_index\": \"test_index\", \"_id\": \"test_id\"}}\n{\"\
        f1\": \"v1\", \"f2\": 42}\n{}\n"
    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"
---
When setting require_alias flag per request:
- requires:
    cluster_features:
    - "gte_v7.10.0"
    reason: "require_alias flag was added in version 7.10"
- do:
    indices.create:
      index: "backing_index"
      body:
        mappings: {}
        aliases:
          test_require_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"
- do:
    bulk:
      refresh: true
      body:
      - index:
          _index: "new_index_not_created"
          require_alias: true
      - f: 1
      - index:
          _index: "new_index_created"
      - f: 2
      - index:
          _index: "test_require_alias"
          require_alias: true
      - f: 3
      - create:
          _index: "test_require_alias"
      - f: 4
    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:
    errors: true
- match:
    items.0.index.status: 404
- match:
    items.0.index.error.type: "index_not_found_exception"
- match:
    items.0.index.error.reason: "no such index [new_index_not_created] and [require_alias]\
      \ request flag is [true] and [new_index_not_created] is not an alias"
- match:
    items.1.index.result: "created"
- match:
    items.2.index.result: "created"
- match:
    items.3.create.result: "created"
- do:
    catch: "missing"
    indices.get:
      index: "new_index_not_created"
    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"
---
When setting require_alias flag:
- requires:
    cluster_features:
    - "gte_v7.10.0"
    reason: "require_alias flag was added in version 7.10"
- do:
    indices.create:
      index: "backing_index"
      body:
        mappings: {}
        aliases:
          test_require_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"
- do:
    bulk:
      refresh: true
      require_alias: true
      body:
      - index:
          _index: "new_index_not_created"
      - f: 1
      - index:
          _index: "new_index_created"
          require_alias: false
      - f: 2
      - index:
          _index: "test_require_alias"
      - f: 3
    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:
    errors: true
- match:
    items.0.index.status: 404
- match:
    items.0.index.error.type: "index_not_found_exception"
- match:
    items.0.index.error.reason: "no such index [new_index_not_created] and [require_alias]\
      \ request flag is [true] and [new_index_not_created] is not an alias"
- match:
    items.1.index.result: "created"
- match:
    items.2.index.result: "created"
- do:
    catch: "missing"
    indices.get:
      index: "new_index_not_created"
    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"
---
Return item-level error when no write index defined for an alias:
- do:
    indices.create:
      index: "test_index1"
    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.create:
      index: "test_index2"
    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.put_alias:
      index: "test_index1"
      name: "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"
- do:
    indices.put_alias:
      index: "test_index2"
      name: "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"
- do:
    bulk:
      body:
      - "{\"index\": {\"_index\": \"test_index\"}}"
      - "{\"field\": \"test\"}"
    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:
    errors: true
- match:
    items.0.index.status: 400
- match:
    items.0.index.error.type: "illegal_argument_exception"
- match:
    items.0.index.error.reason: "no write index is defined for alias [test_index].\
      \ The write index may be explicitly disabled using is_write_index=false or the\
      \ alias points to multiple indices without one being designated as a write index"
---
Took is not orders of magnitude off:
- requires:
    cluster_features:
    - "gte_v8.15.1"
    reason: "Bug reporting wrong took time introduced in 8.15.0, fixed in 8.15.1"
- do:
    bulk:
      body:
      - index:
          _index: "took_test"
      - f: 1
      - index:
          _index: "took_test"
      - f: 2
      - index:
          _index: "took_test"
      - f: 3
    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:
    errors: false
- gte:
    took: 0
- lte:
    took: 60000
