---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    test_runner_features: "allowed_warnings"
- do:
    index:
      index: "index_1"
      id: "1"
      body:
        foo: "bar"
    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:
    index:
      index: "index_1"
      id: "2"
      body:
        foo: "baz"
    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:
    index:
      index: "index_1"
      id: "3"
      body:
        foo: "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"
- do:
    index:
      index: "index_2"
      id: "1"
      body:
        foo: "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"
- do:
    indices.refresh: {}
    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"
---
Basic multi-search:
- do:
    msearch:
      rest_total_hits_as_int: true
      body:
      - index: "index_*"
      - query:
          match:
            foo: "foo"
      - index: "index_2"
      - query:
          match_all: {}
      - index: "index_1"
      - query:
          match:
            foo: "foo"
      - index: "index_3"
      - query:
          match_all: {}
      - {}
      - query:
          match_all: {}
    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:
    responses.0.hits.total: 2
- match:
    responses.1.hits.total: 1
- match:
    responses.2.hits.total: 1
- match:
    responses.3.error.root_cause.0.type: "index_not_found_exception"
- match:
    responses.3.error.root_cause.0.reason: "/no.such.index/"
- match:
    responses.3.error.root_cause.0.index: "index_3"
- match:
    responses.4.hits.total: 4
---
Least impact smoke test:
- do:
    msearch:
      rest_total_hits_as_int: true
      max_concurrent_shard_requests: 1
      max_concurrent_searches: 1
      ignore_unavailable: false
      ignore_throttled: false
      allow_no_indices: false
      expand_wildcards: "open"
      index: "index_*"
      body:
      - index: "index_*"
      - query:
          match:
            foo: "foo"
      - index: "index_2"
      - query:
          match_all: {}
      - index: "index_1"
      - query:
          match:
            foo: "foo"
      - index: "index_3"
      - query:
          match_all: {}
      - {}
      - query:
          match_all: {}
    allowed_warnings:
    - "[ignore_throttled] parameter is deprecated because frozen indices have been\
      \ deprecated. Consider cold or frozen tiers in place of frozen indices."
    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:
    responses.0.hits.total: 2
- match:
    responses.1.hits.total: 1
- match:
    responses.2.hits.total: 1
- match:
    responses.3.error.root_cause.0.type: "index_not_found_exception"
- match:
    responses.3.error.root_cause.0.reason: "/no.such.index/"
- match:
    responses.3.error.root_cause.0.index: "index_3"
- match:
    responses.4.hits.total: 4
---
Smoke test with query score:
- requires:
    cluster_features:
    - "gte_v8.8.0"
    reason: "introduced in 8.8.0"
- do:
    msearch:
      rest_total_hits_as_int: true
      include_named_queries_score: false
      index: "index_*"
      body:
      - index: "index_*"
      - query:
          match:
            foo: "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:
    responses.0.hits.total: 2
---
Search with new response format:
- do:
    msearch:
      body:
      - index: "index_*"
      - query:
          match:
            foo: "foo"
      - index: "index_2"
      - query:
          match_all: {}
      - index: "index_1"
      - query:
          match:
            foo: "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:
    responses.0.hits.total.value: 2
- match:
    responses.0.hits.total.relation: "eq"
- match:
    responses.1.hits.total.value: 1
- match:
    responses.1.hits.total.relation: "eq"
- match:
    responses.2.hits.total.value: 1
- match:
    responses.2.hits.total.relation: "eq"
- do:
    msearch:
      body:
      - index: "index_*"
      - query:
          match:
            foo: "foo"
        track_total_hits: 1
      - index: "index_2"
      - query:
          match_all: {}
      - index: "index_1"
      - query:
          match:
            foo: "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:
    responses.0.hits.total.value: 1
- match:
    responses.0.hits.total.relation: "gte"
- match:
    responses.1.hits.total.value: 1
- match:
    responses.1.hits.total.relation: "eq"
- match:
    responses.2.hits.total.value: 1
- match:
    responses.2.hits.total.relation: "eq"
- do:
    catch: "/\\[rest_total_hits_as_int\\] cannot be used if the tracking of total\
      \ hits is not accurate, got 10/"
    msearch:
      rest_total_hits_as_int: true
      body:
      - index: "index_*"
      - query:
          match_all: {}
        track_total_hits: 10
      - index: "index_2"
      - query:
          match_all: {}
      - index: "index_1"
      - query:
          match:
            foo: "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"
