---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "gte_v7.2.0"
    reason: "added in 7.2.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            my_field1:
              type: "text"
            my_field2:
              type: "text"
    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: "test"
      id: "1"
      body:
        my_field1: "brown fox jump"
        my_field2: "xylophone"
    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: "test"
      id: "2"
      body:
        my_field1: "brown emu jump"
        my_field2: "xylophone"
    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: "test"
      id: "3"
      body:
        my_field1: "jumparound"
        my_field2: "emu"
    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: "test"
      id: "4"
      body:
        my_field1: "dog"
        my_field2: "brown fox jump lazy"
    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"
---
scoring complete term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field1: "brown fox jump"
    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: 3
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
- match:
    hits.hits.1._source.my_field1: "brown emu jump"
- match:
    hits.hits.2._source.my_field1: "jumparound"
---
scoring partial term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field1: "brown fox ju"
    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: 3
- match:
    hits.hits.0._id: "1"
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
- match:
    hits.hits.1._id: "2"
- match:
    hits.hits.1._source.my_field1: "brown emu jump"
- match:
    hits.hits.2._id: "3"
- match:
    hits.hits.2._source.my_field1: "jumparound"
---
minimum should match:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field1:
              query: "brown fox jump"
              minimum_should_match: 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:
    hits.total: 1
- match:
    hits.hits.0._id: "1"
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
---
analyzer:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field1:
              query: "BROWN dog"
              analyzer: "whitespace"
    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: 1
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
---
operator:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field1:
              query: "brown fox jump"
              operator: "AND"
    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: 1
- match:
    hits.hits.0._id: "1"
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
---
fuzziness:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          match_bool_prefix:
            my_field2:
              query: "xylophoen foo"
              fuzziness: 1
              prefix_length: 1
              max_expansions: 10
              fuzzy_transpositions: true
              fuzzy_rewrite: "constant_score"
    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: 2
- match:
    hits.hits.0._source.my_field2: "xylophone"
- match:
    hits.hits.1._source.my_field2: "xylophone"
---
multi_match single field complete term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown fox jump"
            type: "bool_prefix"
            fields:
            - "my_field1"
    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: 3
- match:
    hits.hits.0._id: "1"
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
- match:
    hits.hits.1._id: "2"
- match:
    hits.hits.1._source.my_field1: "brown emu jump"
- match:
    hits.hits.2._id: "3"
- match:
    hits.hits.2._source.my_field1: "jumparound"
---
multi_match single field partial term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown fox ju"
            type: "bool_prefix"
            fields:
            - "my_field1"
    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: 3
- match:
    hits.hits.0._id: "1"
- match:
    hits.hits.0._source.my_field1: "brown fox jump"
- match:
    hits.hits.1._id: "2"
- match:
    hits.hits.1._source.my_field1: "brown emu jump"
- match:
    hits.hits.2._id: "3"
- match:
    hits.hits.2._source.my_field1: "jumparound"
---
multi_match multiple fields complete term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown fox jump lazy"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
    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: 3
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
- match:
    hits.hits.0._source.my_field2: "brown fox jump lazy"
- match:
    hits.hits.1._id: "1"
- match:
    hits.hits.1._source.my_field1: "brown fox jump"
- match:
    hits.hits.2._id: "2"
- match:
    hits.hits.2._source.my_field1: "brown emu jump"
---
multi_match multiple fields partial term:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown fox jump laz"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
    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: 3
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
- match:
    hits.hits.0._source.my_field2: "brown fox jump lazy"
- match:
    hits.hits.1._id: "1"
- match:
    hits.hits.1._source.my_field1: "brown fox jump"
- match:
    hits.hits.2._id: "2"
- match:
    hits.hits.2._source.my_field1: "brown emu jump"
---
multi_match multiple fields with analyzer:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "BROWN FOX JUMP dog"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
            analyzer: "whitespace"
    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: 1
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
- match:
    hits.hits.0._source.my_field2: "brown fox jump lazy"
---
multi_match multiple fields with minimum_should_match:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown fox jump la"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
            minimum_should_match: 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:
    hits.total: 1
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
- match:
    hits.hits.0._source.my_field2: "brown fox jump lazy"
---
multi_match multiple fields with fuzziness:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "dob nomatch"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
            fuzziness: 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"
- match:
    hits.total: 1
- match:
    hits.hits.0._id: "4"
- match:
    hits.hits.0._source.my_field1: "dog"
- match:
    hits.hits.0._source.my_field2: "brown fox jump lazy"
---
multi_match multiple fields with boost:
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown emu"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2^10"
            fuzziness: 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"
- match:
    hits.hits.0._id: "3"
- match:
    hits.hits.0._source.my_field2: "emu"
---
multi_match multiple fields with slop throws exception:
- do:
    catch: "/\\[slop\\] not allowed for type \\[bool_prefix\\]/"
    search:
      rest_total_hits_as_int: true
      index: "test"
      body:
        query:
          multi_match:
            query: "brown"
            type: "bool_prefix"
            fields:
            - "my_field1"
            - "my_field2"
            slop: 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"
