---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
routing:
- do:
    indices.create:
      index: "test_1"
      body:
        settings:
          index:
            number_of_shards: 5
            number_of_replicas: 0
    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:
    cluster.health:
      wait_for_status: "green"
    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_1"
      id: "1"
      routing: "5"
      body:
        foo: "bar 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:
    mtermvectors:
      index: "test_1"
      fields: "foo"
      body:
        docs:
        - _id: "1"
        - _id: "1"
          routing: "4"
        - _id: "1"
          routing: "5"
    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: "docs.0.found"
- is_false: "docs.1.found"
- is_true: "docs.2.found"
- match:
    docs.2._index: "test_1"
- match:
    docs.2._id: "1"
- match:
    docs.2.term_vectors.foo.terms.bar.term_freq: 1
- match:
    docs.2.term_vectors.foo.terms.baz.term_freq: 1
---
requires routing:
- requires:
    cluster_features:
    - "gte_v8.0.0"
    reason: "fails with an unexpected message in 7.x"
- do:
    indices.create:
      index: "test_1"
      body:
        settings:
          index:
            number_of_shards: 5
            number_of_replicas: 0
        mappings:
          _routing:
            required: true
    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_1"
      id: "1"
      routing: "5"
      body:
        foo: "bar 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:
    indices.put_alias:
      index: "test_1"
      name: "alias"
    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:
    mtermvectors:
      fields: "foo"
      body:
        docs:
        - _id: "1"
          _index: "test_1"
        - _id: "1"
          _index: "alias"
        - _id: "1"
          _index: "test_1"
          routing: "5"
    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: "docs.0.found"
- match:
    docs.0.error.reason: "routing is required for [test_1]/[1]"
- match:
    docs.0._index: "test_1"
- is_false: "docs.1.found"
- match:
    docs.1.error.reason: "routing is required for [test_1]/[1]"
- match:
    docs.1._index: "test_1"
- is_true: "docs.2.found"
- match:
    docs.2._index: "test_1"
- match:
    docs.2._id: "1"
- match:
    docs.2.term_vectors.foo.terms.bar.term_freq: 1
- match:
    docs.2.term_vectors.foo.terms.baz.term_freq: 1
