---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Basic /_search_shards test:
- do:
    indices.create:
      index: "test_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:
    search_shards:
      index: "test_1"
      routing: "foo"
    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:
    shards.0.0.index: "test_1"
---
Search shards aliases with and without filters:
- do:
    indices.create:
      index: "test_index"
      body:
        settings:
          index:
            number_of_shards: 1
        mappings:
          properties:
            field:
              type: "text"
        aliases:
          test_alias_no_filter: {}
          test_alias_filter_1:
            filter:
              term:
                field: "value1"
          test_alias_filter_2:
            filter:
              term:
                field: "value2"
    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:
    search_shards:
      index: "test_alias_no_filter"
    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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- is_true: "indices.test_index"
- is_false: "indices.test_index.filter"
- match:
    indices.test_index.aliases:
    - "test_alias_no_filter"
- do:
    search_shards:
      index: "test_alias_filter_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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- match:
    indices.test_index.aliases:
    - "test_alias_filter_1"
- match:
    indices.test_index.filter.term.field.value: "value1"
- do:
    search_shards:
      index:
      - "test_alias_filter_1"
      - "test_alias_filter_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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- match:
    indices.test_index.aliases:
    - "test_alias_filter_1"
    - "test_alias_filter_2"
- length:
    indices.test_index.filter.bool.should: 2
- do:
    search_shards:
      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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- match:
    indices.test_index.aliases:
    - "test_alias_filter_1"
    - "test_alias_filter_2"
    - "test_alias_no_filter"
- is_false: "indices.test_index.filter"
- do:
    search_shards:
      index:
      - "test_alias_filter_1"
      - "test_alias_no_filter"
    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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- match:
    indices.test_index.aliases:
    - "test_alias_filter_1"
    - "test_alias_no_filter"
- is_false: "indices.test_index.filter"
- do:
    search_shards:
      index:
      - "test_alias_no_filter"
    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"
- length:
    shards: 1
- match:
    shards.0.0.index: "test_index"
- match:
    indices.test_index.aliases:
    - "test_alias_no_filter"
- is_false: "indices.test_index.filter"
