---
setup:
- skip:
    known_issues:
    - cluster_feature: "gte_v8.7.0"
      fixed_by: "gte_v8.10.0"
    reason: "Synthetic source shows up in the mapping in 8.10 and on, may trigger\
      \ assert failures in mixed cluster tests"
    features:
    - "headers"
    - "allowed_warnings_regex"
---
add time series mappings:
- requires:
    cluster_features:
    - "gte_v7.16.0"
    reason: "introduced in 7.16.0"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: true
            k8s:
              properties:
                pod:
                  properties:
                    availability_zone:
                      type: "short"
                      time_series_dimension: true
                    uid:
                      type: "keyword"
                      time_series_dimension: true
                    name:
                      type: "keyword"
                    ip:
                      type: "ip"
                      time_series_dimension: true
                    network:
                      properties:
                        tx:
                          type: "long"
                          time_series_metric: "counter"
                        rx:
                          type: "integer"
                          time_series_metric: "gauge"
                        packets_dropped:
                          type: "long"
                          time_series_metric: "gauge"
                        latency:
                          type: "double"
                          time_series_metric: "gauge"
    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"
---
can shadow dimensions:
- requires:
    cluster_features:
    - "index.shadowing_dimensions_and_metrics_is_valid_in_non_tsdb"
    reason: "Fixed by #141549"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
            dim:
              type: "keyword"
              time_series_dimension: true
            deep:
              properties:
                deeper:
                  properties:
                    deepest:
                      type: "keyword"
                      time_series_dimension: 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:
    indices.put_mapping:
      index: "test"
      body:
        runtime:
          dim:
            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"
- is_true: "acknowledged"
- do:
    search:
      index: "test"
      body:
        runtime_mappings:
          dim:
            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:
    indices.put_mapping:
      index: "test"
      body:
        runtime:
          deep.deeper.deepest:
            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"
- is_true: "acknowledged"
- do:
    search:
      index: "test"
      body:
        runtime_mappings:
          deep.deeper.deepest:
            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"
---
can shadow metrics:
- requires:
    cluster_features:
    - "index.shadowing_dimensions_and_metrics_is_valid_in_non_tsdb"
    reason: "Fixed by #141549"
- do:
    indices.create:
      index: "test"
      body:
        settings:
          index:
            number_of_shards: 2
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metric:
              type: "long"
              time_series_metric: "gauge"
            deep:
              properties:
                deeper:
                  properties:
                    deepest:
                      type: "long"
                      time_series_metric: "gauge"
    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_mapping:
      index: "test"
      body:
        runtime:
          metric:
            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"
- is_true: "acknowledged"
- do:
    search:
      index: "test"
      body:
        runtime_mappings:
          metric:
            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:
    indices.put_mapping:
      index: "test"
      body:
        runtime:
          deep.deeper.deepest:
            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:
    search:
      index: "test"
      body:
        runtime_mappings:
          deep.deeper.deepest:
            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"
---
no _tsid in standard indices:
- requires:
    cluster_features:
    - "gte_v8.5.0"
    reason: "time series params only on time series indices introduced in 8.5.0"
- do:
    indices.create:
      index: "test"
      body:
        mappings:
          properties:
            '@timestamp':
              type: "date"
            metricset:
              type: "keyword"
              time_series_dimension: 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:
    field_caps:
      index: "test"
      fields:
      - "metricset"
      - "_tsid"
    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:
    fields.metricset.keyword.searchable: true
- match:
    fields.metricset.keyword.aggregatable: true
- is_false: "fields.metricset.keyword.indices"
- is_false: "fields.metricset.keyword.non_searchable_indices"
- is_false: "fields.metricset.keyword.non_aggregatable_indices"
- is_false: "fields._tsid"
- is_false: "fields.metricset.keyword.time_series_dimension"
---
no nested dimensions:
- requires:
    cluster_features:
    - "gte_v8.2.0"
    reason: "introduced in 8.2.0"
- do:
    catch: "/time_series_dimension can't be configured in nested field \\[nested.dim\\\
      ]/"
    indices.create:
      index: "test"
      body:
        mappings:
          properties:
            '@timestamp':
              type: "date"
            nested:
              type: "nested"
              properties:
                dim:
                  type: "keyword"
                  time_series_dimension: 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"
