---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Search with response filtering:
- do:
    indices.create:
      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"
- do:
    index:
      index: "test"
      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: "test"
      id: "2"
      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:
    indices.refresh:
      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"
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      filter_path: "*"
      body: "{ \"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"
- gte:
    took: 0
- is_false: "_clusters"
- is_true: "_shards.total"
- is_true: "hits.total"
- is_true: "hits.hits.0._index"
- is_true: "hits.hits.0._id"
- is_true: "hits.hits.1._index"
- is_true: "hits.hits.1._id"
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      filter_path: "took"
      body: "{ \"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"
- gte:
    took: 0
- is_false: "_shards.total"
- is_false: "hits.total"
- is_false: "hits.hits.0._index"
- is_false: "hits.hits.0._id"
- is_false: "hits.hits.1._index"
- is_false: "hits.hits.1._id"
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      filter_path: "_shards.*"
      body: "{ \"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"
- is_false: "took"
- is_true: "_shards.total"
- is_false: "hits.total"
- is_false: "hits.hits.0._index"
- is_false: "hits.hits.0._id"
- is_false: "hits.hits.1._index"
- is_false: "hits.hits.1._id"
- do:
    search:
      rest_total_hits_as_int: true
      index: "test"
      filter_path:
      - "hits.**._i*"
      - "**.total"
      body: "{ \"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"
- is_false: "took"
- is_true: "_shards.total"
- is_true: "hits.total"
- is_true: "hits.hits.0._index"
- is_true: "hits.hits.0._id"
- is_true: "hits.hits.1._index"
- is_true: "hits.hits.1._id"
---
Search results filtered using both includes and excludes filters:
- do:
    bulk:
      refresh: true
      body: "{\"index\": {\"_index\": \"index-1\", \"_id\": \"1\"}}\n{\"name\": \"\
        First document\", \"properties\": {\"size\": 123, \"meta\": {\"foo\": \"bar\"\
        }}}\n{\"index\": {\"_index\": \"index-1\", \"_id\": \"2\"}}\n{\"name\": \"\
        Second document\", \"properties\": {\"size\": 465, \"meta\": {\"foo\": \"\
        bar\", \"baz\": \"qux\"}}}\n"
    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:
      rest_total_hits_as_int: true
      filter_path:
      - "-**._source.properties"
      - "**._source"
      body:
        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"
- is_false: "took"
- is_true: "hits.hits.0._source"
- is_true: "hits.hits.0._source.name"
- is_false: "hits.hits.0._source.properties"
- is_true: "hits.hits.1._source"
- is_true: "hits.hits.1._source.name"
- is_false: "hits.hits.1._source.properties"
- do:
    search:
      rest_total_hits_as_int: true
      filter_path:
      - "**.properties"
      - "-hits.hits._source.properties.meta"
      body:
        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"
- is_false: "took"
- is_true: "hits.hits.0._source"
- is_false: "hits.hits.0._source.name"
- is_true: "hits.hits.0._source.properties"
- is_true: "hits.hits.0._source.properties.size"
- is_false: "hits.hits.0._source.properties.meta"
- is_true: "hits.hits.1._source"
- is_false: "hits.hits.1._source.name"
- is_true: "hits.hits.1._source.properties"
- is_true: "hits.hits.1._source.properties.size"
- is_false: "hits.hits.1._source.properties.meta"
- do:
    search:
      rest_total_hits_as_int: true
      filter_path: "**._source,-**.meta.foo"
      body:
        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"
- is_false: "took"
- is_true: "hits.hits.0._source"
- is_true: "hits.hits.0._source.name"
- is_true: "hits.hits.0._source.properties"
- is_true: "hits.hits.0._source.properties.size"
- is_false: "hits.hits.0._source.properties.meta.foo"
- do:
    count:
      filter_path: "-*"
      body:
        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"
- is_false: "count"
- is_false: "_shards"
