---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
named_queries:
- requires:
    cluster_features:
    - "gte_v8.8.0"
    reason: "introduced in 8.8.0"
- do:
    bulk:
      refresh: true
      body:
      - "{ \"index\" : { \"_index\" : \"test_1\", \"_id\" : \"1\" } }"
      - "{\"field\" : 1 }"
      - "{ \"index\" : { \"_index\" : \"test_1\", \"_id\" : \"2\" } }"
      - "{\"field\" : [1, 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"
- do:
    search:
      index: "test_1"
      body:
        query:
          bool:
            should:
            - match:
                field:
                  query: 1
                  _name: "match_field_1"
            - match:
                field:
                  query: 2
                  _name: "match_field_2"
                  boost: 10
    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:
    hits.total.value: 2
- length:
    hits.hits.0.matched_queries: 2
- match:
    hits.hits.0.matched_queries:
    - "match_field_1"
    - "match_field_2"
- length:
    hits.hits.1.matched_queries: 1
- match:
    hits.hits.1.matched_queries:
    - "match_field_1"
---
named_queries_with_score:
- requires:
    cluster_features:
    - "gte_v8.8.0"
    reason: "introduced in 8.8.0"
- do:
    bulk:
      refresh: true
      body:
      - "{ \"index\" : { \"_index\" : \"test_1\", \"_id\" : \"1\" } }"
      - "{\"field\" : 1 }"
      - "{ \"index\" : { \"_index\" : \"test_1\", \"_id\" : \"2\" } }"
      - "{\"field\" : [1, 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"
- do:
    search:
      include_named_queries_score: true
      index: "test_1"
      body:
        query:
          bool:
            should:
            - match:
                field:
                  query: 1
                  _name: "match_field_1"
            - match:
                field:
                  query: 2
                  _name: "match_field_2"
                  boost: 10
    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:
    hits.total.value: 2
- length:
    hits.hits.0.matched_queries: 2
- match:
    hits.hits.0.matched_queries.match_field_1: 1
- match:
    hits.hits.0.matched_queries.match_field_2: 10
- length:
    hits.hits.1.matched_queries: 1
- match:
    hits.hits.1.matched_queries.match_field_1: 1
