---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- requires:
    cluster_features:
    - "gte_v7.15.0"
    reason: "analyze index disk usage API is introduced in 7.15"
- do:
    indices.create:
      index: "testindex"
      body:
        mappings:
          properties:
            name:
              type: "text"
            quantity:
              type: "long"
              doc_values: false
            genre:
              type: "keyword"
              doc_values: 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: "testindex"
      body:
        name: "foo"
        quantity: 0
        genre:
        - "rock"
        - "pop"
    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: "testindex"
      body:
        name: "bar"
        quantity: 99
        genre: "pop"
    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: "testindex"
      body:
        name: "baz"
        quantity: 50
        genre: "jazz"
    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: "testindex"
      body:
        name: "bar & baz"
        quantity: 1000
        genre: "blue"
    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: "testindex"
      body:
        name: "foobar"
        quantity: 1000
        genre: "country"
    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"
---
Name the index:
- do:
    indices.disk_usage:
      index: "testindex"
      run_expensive_tasks: 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"
- gt:
    testindex.store_size_in_bytes: 100
- gt:
    testindex.all_fields.total_in_bytes: 0
- gt:
    testindex.all_fields.inverted_index.total_in_bytes: 0
- gt:
    testindex.all_fields.stored_fields_in_bytes: 0
- gt:
    testindex.all_fields.doc_values_in_bytes: 0
- gt:
    testindex.all_fields.points_in_bytes: 0
- match:
    testindex.all_fields.term_vectors_in_bytes: 0
- gt:
    testindex.fields.genre.total_in_bytes: 0
- gt:
    testindex.fields.genre.inverted_index.total_in_bytes: 0
- match:
    testindex.fields.genre.stored_fields_in_bytes: 0
- gt:
    testindex.fields.genre.doc_values_in_bytes: 0
- match:
    testindex.fields.genre.points_in_bytes: 0
- match:
    testindex.fields.genre.norms_in_bytes: 0
- match:
    testindex.fields.genre.term_vectors_in_bytes: 0
- gt:
    testindex.fields.name.total_in_bytes: 0
- gt:
    testindex.fields.name.inverted_index.total_in_bytes: 0
- match:
    testindex.fields.name.stored_fields_in_bytes: 0
- match:
    testindex.fields.name.doc_values_in_bytes: 0
- match:
    testindex.fields.name.points_in_bytes: 0
- match:
    testindex.fields.name.term_vectors_in_bytes: 0
- gt:
    testindex.fields.quantity.total_in_bytes: 0
- match:
    testindex.fields.quantity.inverted_index.total_in_bytes: 0
- match:
    testindex.fields.quantity.stored_fields_in_bytes: 0
- match:
    testindex.fields.quantity.doc_values_in_bytes: 0
- gt:
    testindex.fields.quantity.points_in_bytes: 0
- match:
    testindex.fields.quantity.norms_in_bytes: 0
- match:
    testindex.fields.quantity.term_vectors_in_bytes: 0
- gt:
    testindex.fields._source.total_in_bytes: 0
- match:
    testindex.fields._source.inverted_index.total_in_bytes: 0
- gt:
    testindex.fields._source.stored_fields_in_bytes: 0
- match:
    testindex.fields._source.doc_values_in_bytes: 0
- match:
    testindex.fields._source.points_in_bytes: 0
- match:
    testindex.fields._source.norms_in_bytes: 0
- match:
    testindex.fields._source.term_vectors_in_bytes: 0
- gt:
    testindex.fields._id.total_in_bytes: 0
- gt:
    testindex.fields._id.inverted_index.total_in_bytes: 0
- gt:
    testindex.fields._id.stored_fields_in_bytes: 0
- match:
    testindex.fields._id.doc_values_in_bytes: 0
- match:
    testindex.fields._id.points_in_bytes: 0
- match:
    testindex.fields._id.norms_in_bytes: 0
- match:
    testindex.fields._id.term_vectors_in_bytes: 0
- gt:
    testindex.fields._seq_no.total_in_bytes: 0
- match:
    testindex.fields._seq_no.inverted_index.total_in_bytes: 0
- match:
    testindex.fields._seq_no.stored_fields_in_bytes: 0
- gt:
    testindex.fields._seq_no.points_in_bytes: 0
- match:
    testindex.fields._seq_no.norms_in_bytes: 0
- match:
    testindex.fields._seq_no.term_vectors_in_bytes: 0
---
Star:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "star is resolved in 8.2+"
- do:
    indices.disk_usage:
      index: "*"
      run_expensive_tasks: 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"
- gt:
    testindex.store_size_in_bytes: 100
- gt:
    testindex.all_fields.total_in_bytes: 0
- gt:
    testindex.all_fields.inverted_index.total_in_bytes: 0
- gt:
    testindex.all_fields.stored_fields_in_bytes: 0
- gt:
    testindex.all_fields.doc_values_in_bytes: 0
- gt:
    testindex.all_fields.points_in_bytes: 0
- match:
    testindex.all_fields.term_vectors_in_bytes: 0
---
Dense vectors:
- requires:
    cluster_features:
    - "gte_v8.4.0"
    reason: "dense vector support was added in 8.4"
- do:
    indices.put_mapping:
      index: "testindex"
      body:
        properties:
          vector:
            type: "dense_vector"
            dims: 3
            index: true
            similarity: "l2_norm"
    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: "testindex"
      body:
        quantity: 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:
    index:
      index: "testindex"
      body:
        quantity: 99
        vector:
        - 0.1
        - 0.2
        - 0.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"
- do:
    index:
      index: "testindex"
      body:
        quantity: 1000
        vector:
        - 1.3
        - 0.2
        - 4.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"
- do:
    indices.disk_usage:
      index: "testindex"
      run_expensive_tasks: 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"
- gt:
    testindex.store_size_in_bytes: 100
- gt:
    testindex.all_fields.knn_vectors_in_bytes: 0
- gt:
    testindex.fields.quantity.total_in_bytes: 0
- gt:
    testindex.fields.quantity.points_in_bytes: 0
- match:
    testindex.fields.quantity.knn_vectors_in_bytes: 0
- gt:
    testindex.fields.vector.total_in_bytes: 0
- match:
    testindex.fields.vector.points_in_bytes: 0
- gt:
    testindex.fields.vector.knn_vectors_in_bytes: 0
