---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Terms Query with No.of terms exceeding index.max_terms_count should FAIL:
- do:
    indices.create:
      index: "test_index"
      body:
        settings:
          number_of_shards: 1
          index.max_terms_count: 2
        mappings:
          properties:
            user:
              type: "keyword"
            followers:
              type: "keyword"
    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:
    bulk:
      refresh: true
      body:
      - "{\"index\": {\"_index\": \"test_index\", \"_id\": \"u1\"}}"
      - "{\"user\": \"u1\", \"followers\": [\"u2\", \"u3\"]}"
      - "{\"index\": {\"_index\": \"test_index\", \"_id\": \"u2\"}}"
      - "{\"user\": \"u2\", \"followers\": [\"u1\", \"u3\", \"u4\"]}"
      - "{\"index\": {\"_index\": \"test_index\", \"_id\": \"u3\"}}"
      - "{\"user\": \"u3\", \"followers\": [\"u1\"]}"
      - "{\"index\": {\"_index\": \"test_index\", \"_id\": \"u4\"}}"
      - "{\"user\": \"u4\", \"followers\": [\"u3\"]}"
    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_index"
      body:
        query:
          terms:
            user:
            - "u1"
            - "u2"
    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
- do:
    catch: "bad_request"
    search:
      rest_total_hits_as_int: true
      index: "test_index"
      body:
        query:
          terms:
            user:
            - "u1"
            - "u2"
            - "u3"
    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_index"
      body:
        query:
          terms:
            user:
              index: "test_index"
              id: "u1"
              path: "followers"
    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
- do:
    catch: "bad_request"
    search:
      rest_total_hits_as_int: true
      index: "test_index"
      body:
        query:
          terms:
            user:
              index: "test_index"
              id: "u2"
              path: "followers"
    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"
