---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    bulk:
      index: "test"
      refresh: true
      body:
      - "{\"index\": {}}"
      - "{\"v1\": 15.2, \"v2\": 15.9, \"str\": \"a\"}"
      - "{\"index\": {}}"
      - "{\"v1\": 15.3, \"v2\": 15.9, \"str\": \"a\"}"
      - "{\"index\": {}}"
      - "{\"v1\": 16.0, \"v2\": 15.2, \"str\": \"b\"}"
      - "{\"index\": {}}"
      - "{\"v1\": 15.1, \"v2\": 15.5, \"str\": \"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"
---
heteroscedastic t-test:
- do:
    search:
      size: 0
      index: "test"
      body:
        aggs:
          ttest:
            t_test:
              a:
                field: "v1"
              b:
                field: "v2"
    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.ttest.value: 0.43066659210472646
---
paired t-test:
- do:
    search:
      size: 0
      index: "test"
      body:
        aggs:
          ttest:
            t_test:
              a:
                field: "v1"
              b:
                field: "v2"
              type: "paired"
    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.ttest.value: 0.5632529432617406
---
homoscedastic t-test with filters:
- do:
    search:
      size: 0
      index: "test"
      body:
        aggs:
          ttest:
            t_test:
              a:
                field: "v1"
                filter:
                  term:
                    str.keyword: "a"
              b:
                field: "v1"
                filter:
                  term:
                    str.keyword: "b"
              type: "homoscedastic"
    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.ttest.value: 0.5757355806262943
