---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "test"
      body:
        mappings:
          properties:
            value:
              type: "keyword"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- do:
    bulk:
      index: "test"
      refresh: true
      body:
      - "{\"index\": {}}"
      - "{\"value\": \"a\"}"
      - "{\"index\": {}}"
      - "{\"value\": \"b\"}"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
basic:
- do:
    search:
      size: 0
      body:
        aggs:
          my_agg:
            string_stats:
              field: "value"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    aggregations.my_agg.count: 2
- match:
    aggregations.my_agg.min_length: 1
- match:
    aggregations.my_agg.max_length: 1
- match:
    aggregations.my_agg.avg_length: 1.0
- match:
    aggregations.my_agg.entropy: 1.0
---
show_distribution:
- do:
    search:
      size: 0
      body:
        aggs:
          my_agg:
            string_stats:
              field: "value"
              show_distribution: true
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    aggregations.my_agg.count: 2
- match:
    aggregations.my_agg.min_length: 1
- match:
    aggregations.my_agg.max_length: 1
- match:
    aggregations.my_agg.avg_length: 1.0
- match:
    aggregations.my_agg.entropy: 1.0
- match:
    aggregations.my_agg.distribution.a: 0.5
- match:
    aggregations.my_agg.distribution.b: 0.5
