---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    indices.create:
      index: "store"
      body:
        mappings:
          properties:
            features:
              type: "keyword"
            error_message:
              type: "keyword"
            timestamp:
              type: "date"
            geo_point:
              type: "geo_point"
            histogram:
              type: "histogram"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    bulk:
      index: "store"
      refresh: true
      body: "{ \"index\": {} }\n{ \"features\": [\"turbocharger\", \"electric mirror\"\
        , \"heated steering wheel\", \"matrix led\", \"gps\", \"sunroof\", \"autopilot\"\
        , \"air condition\"], \"error_message\": \"compressor low pressure\", \"timestamp\"\
        : 1020229654000 }\n{ \"index\": {} }\n{ \"features\": [\"pink wheels\", \"\
        turbocharger\", \"lane assist\", \"matrix led\", \"coming home\", \"heated\
        \ seats\", \"blind spot monitoring\", \"air condition\"], \"error_message\"\
        : \"engine overheated\", \"timestamp\": 1020316054000 }\n{ \"index\": {} }\n\
        { \"features\": [\"awd\", \"tow-bar\", \"matrix led\", \"gps\", \"sunroof\"\
        , \"air condition\"], \"error_message\": \"compressor low pressure\", \"timestamp\"\
        : 1022742044000 }\n{ \"index\": {} }\n{ \"features\": [\"rwd\", \"tow-bar\"\
        , \"turbocharger\", \"lane assist\", \"pink wheels\"], \"error_message\":\
        \ \"engine overheated\", \"timestamp\": 1021532444000 }\n{ \"index\": {} }\n\
        { \"features\": [\"pink wheels\", \"sunroof\", \"air condition\"], \"error_message\"\
        : \"compressor low pressure\", \"timestamp\": 1020575254000 }\n{ \"index\"\
        : {} }\n{ \"features\": [\"turbocharger\", \"pink wheels\", \"air condition\"\
        \ ], \"error_message\": \"engine overheated\", \"timestamp\": 1020322844000\
        \ }\n{ \"index\": {} }\n{ \"features\": [\"awd\", \"heated steering wheel\"\
        , \"sunroof\", \"air condition\"], \"error_message\": \"compressor low pressure\"\
        , \"timestamp\": 1020748054000 }\n{ \"index\": {} }\n{ \"features\": [\"turbocharger\"\
        , \"sunroof\", \"autopilot\", \"air condition\" ], \"error_message\": \"compressor\
        \ low pressure\", \"timestamp\": 1020229654000 }\n{ \"index\": {} }\n{ \"\
        features\": [\"rwd\", \"turbocharger\", \"autopilot\", \"pink wheels\"], \"\
        error_message\": \"engine overheated\", \"timestamp\": 1022137244000 }\n{\
        \ \"index\": {} }\n{ \"features\": [\"fwd\", \"tow-bar\", \"turbocharger\"\
        , \"pink wheels\", \"electric mirror\", \"heated steering wheel\", \"lane\
        \ assist\", \"sunroof\", \"autopilot\", \"air condition\" ], \"error_message\"\
        : \"low tire pressure\", \"timestamp\": 1020920854000 }\n"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    indices.create:
      index: "store-flattened"
      body:
        mappings:
          properties:
            data:
              type: "flattened"
            timestamp:
              type: "date"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    bulk:
      index: "store-flattened"
      refresh: true
      body: "{ \"index\": {} }\n{ \"data\": {\"features\": [\"turbocharger\", \"electric\
        \ mirror\", \"heated steering wheel\", \"matrix led\", \"gps\", \"sunroof\"\
        , \"autopilot\", \"air condition\"], \"error_message\": \"compressor low pressure\"\
        }, \"timestamp\": 1020229654000 }\n{ \"index\": {} }\n{ \"data\": {\"features\"\
        : [\"pink wheels\", \"turbocharger\", \"lane assist\", \"matrix led\", \"\
        coming home\", \"heated seats\", \"blind spot monitoring\", \"air condition\"\
        ], \"error_message\": \"engine overheated\"}, \"timestamp\": 1020316054000\
        \ }\n{ \"index\": {} }\n{ \"data\": {\"features\": [\"awd\", \"tow-bar\",\
        \ \"matrix led\", \"gps\", \"sunroof\", \"air condition\"], \"error_message\"\
        : \"compressor low pressure\"}, \"timestamp\": 1022742044000 }\n{ \"index\"\
        : {} }\n{ \"data\": {\"features\": [\"rwd\", \"tow-bar\", \"turbocharger\"\
        , \"lane assist\", \"pink wheels\"], \"error_message\": \"engine overheated\"\
        }, \"timestamp\": 1021532444000 }\n{ \"index\": {} }\n{ \"data\": {\"features\"\
        : [\"pink wheels\", \"sunroof\", \"air condition\"], \"error_message\": \"\
        compressor low pressure\"}, \"timestamp\": 1020575254000 }\n{ \"index\": {}\
        \ }\n{ \"data\": {\"features\": [\"turbocharger\", \"pink wheels\", \"air\
        \ condition\" ], \"error_message\": \"engine overheated\"}, \"timestamp\"\
        : 1020322844000 }\n{ \"index\": {} }\n{ \"data\": {\"features\": [\"awd\"\
        , \"heated steering wheel\", \"sunroof\", \"air condition\"], \"error_message\"\
        : \"compressor low pressure\"}, \"timestamp\": 1020748054000 }\n{ \"index\"\
        : {} }\n{ \"data\": {\"features\": [\"turbocharger\", \"sunroof\", \"autopilot\"\
        , \"air condition\" ], \"error_message\": \"compressor low pressure\"}, \"\
        timestamp\": 1020229654000 }\n{ \"index\": {} }\n{ \"data\": {\"features\"\
        : [\"rwd\", \"turbocharger\", \"autopilot\", \"pink wheels\"], \"error_message\"\
        : \"engine overheated\"}, \"timestamp\": 1022137244000 }\n{ \"index\": {}\
        \ }\n{ \"data\": {\"features\": [\"fwd\", \"tow-bar\", \"turbocharger\", \"\
        pink wheels\", \"electric mirror\", \"heated steering wheel\", \"lane assist\"\
        , \"sunroof\", \"autopilot\", \"air condition\" ], \"error_message\": \"low\
        \ tire pressure\"}, \"timestamp\": 1020920854000 }\n"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    indices.create:
      index: "unavailable-data"
      body:
        mappings:
          properties:
            features:
              type: "keyword"
            error_message:
              type: "keyword"
            timestamp:
              type: "date"
            geo_point:
              type: "geo_point"
            histogram:
              type: "histogram"
    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:
    headers:
      Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=="
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    cluster.health:
      wait_for_status: "yellow"
    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"
---
Test frequent item sets array fields:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"}\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 4
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- match:
    aggregations.fi.buckets.1.doc_count: 4
- match:
    aggregations.fi.buckets.1.support: 0.4
- match:
    aggregations.fi.buckets.1.key.error_message:
    - "engine overheated"
---
Test frequent item sets date format:
- do:
    search:
      index: "store"
      body: "{\n  \"runtime_mappings\": {\n    \"weekday\": {\n      \"type\": \"\
        keyword\",\n      \"script\": {\n      \"source\": \"emit(doc['timestamp'].value.format(DateTimeFormatter.ofPattern('EEE')));\"\
        \n      }\n    }\n  },\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n   \
        \   \"frequent_item_sets\": {\n        \"minimum_set_size\": 3,\n        \"\
        minimum_support\": 0.3,\n        \"fields\": [\n          {\"field\": \"features\"\
        },\n          {\"field\": \"weekday\"}\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 3
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.weekday:
    - "Thu"
---
Test frequent item sets date format 2:
- do:
    search:
      index: "store"
      body: "{\n  \"runtime_mappings\": {\n    \"weekday\": {\n      \"type\": \"\
        keyword\",\n      \"script\": {\n      \"source\": \"emit(doc['timestamp'].value.format(DateTimeFormatter.ofPattern('EEE')));\"\
        \n      }\n    }\n  },\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n   \
        \   \"frequent_item_sets\": {\n        \"minimum_set_size\": 2,\n        \"\
        minimum_support\": 0.3,\n        \"fields\": [\n          {\"field\": \"error_message\"\
        },\n          {\"field\": \"weekday\"}\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 1
- match:
    aggregations.fi.buckets.0.doc_count: 4
- match:
    aggregations.fi.buckets.0.support: 0.4
- match:
    aggregations.fi.buckets.0.key.weekday:
    - "Thu"
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "engine overheated"
---
Test frequent item sets array fields profile:
- do:
    search:
      index: "store"
      body: "{\n  \"profile\": true,\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n\
        \      \"frequent_item_sets\": {\n        \"minimum_set_size\": 3,\n     \
        \   \"minimum_support\": 0.2,\n        \"fields\": [\n          {\"field\"\
        : \"features\"},\n          {\"field\": \"error_message\"}\n        ]\n  \
        \    }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 10
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- match:
    aggregations.fi.buckets.1.doc_count: 4
- match:
    aggregations.fi.buckets.1.support: 0.4
- match:
    aggregations.fi.buckets.1.key.error_message:
    - "engine overheated"
- match:
    aggregations.fi.buckets.1.support: 0.4
- match:
    aggregations.fi.profile.unique_transactions_after_prune: 10
- match:
    aggregations.fi.profile.unique_items_after_prune: 11
---
Test frequent item sets flattened fields:
- do:
    search:
      index: "store-flattened"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"data.features\"},\n      \
        \    {\"field\": \"data.error_message\"}\n        ]\n      }\n    }\n  }\n\
        }\n"
    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"
- length:
    aggregations.fi.buckets: 4
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.data\.error_message:
    - "compressor low pressure"
- match:
    aggregations.fi.buckets.1.doc_count: 4
- match:
    aggregations.fi.buckets.1.support: 0.4
- match:
    aggregations.fi.buckets.1.key.data\.error_message:
    - "engine overheated"
---
Test frequent item sets as subagg:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"filter_error\": {\n      \"filter\"\
        : {\n        \"term\": {\n          \"error_message\": \"compressor low pressure\"\
        \n        }\n      },\n      \"aggs\": {\n        \"fi\": {\n          \"\
        frequent_item_sets\": {\n            \"minimum_set_size\": 3,\n          \
        \  \"minimum_support\": 0.3,\n            \"fields\": [\n              {\"\
        field\": \"features\"},\n              {\"field\": \"error_message\"}\n  \
        \          ]\n          }\n        }\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.filter_error.fi.buckets: 5
- match:
    aggregations.filter_error.fi.buckets.0.doc_count: 5
- match:
    aggregations.filter_error.fi.buckets.0.support: 1.0
- match:
    aggregations.filter_error.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- match:
    aggregations.filter_error.fi.buckets.1.doc_count: 2
- match:
    aggregations.filter_error.fi.buckets.1.support: 0.4
- match:
    aggregations.filter_error.fi.buckets.0.key.error_message:
    - "compressor low pressure"
---
Test frequent item sets as multi-bucket subagg:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"weekly\": {\n      \"date_histogram\"\
        : {\n        \"field\": \"timestamp\",\n        \"calendar_interval\": \"\
        1w\"\n      },\n      \"aggs\": {\n        \"fi\": {\n          \"frequent_item_sets\"\
        : {\n            \"minimum_set_size\": 3,\n            \"minimum_support\"\
        : 0.3,\n            \"fields\": [\n              {\"field\": \"features\"\
        },\n              {\"field\": \"error_message\"}\n            ]\n        \
        \  }\n        }\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.weekly.buckets: 5
- match:
    aggregations.weekly.buckets.0.fi.buckets.0.doc_count: 3
- match:
    aggregations.weekly.buckets.0.fi.buckets.0.support: 0.6
- match:
    aggregations.weekly.buckets.0.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- length:
    aggregations.weekly.buckets.0.fi.buckets: 4
- match:
    aggregations.weekly.buckets.2.fi.buckets.0.doc_count: 1
---
Test frequent item sets filter:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"}\n        ],\n        \"filter\": {\n         \
        \ \"bool\": {\n            \"must_not\": {\n              \"term\": {\"features\"\
        : \"pink wheels\"}\n            }\n          }\n        }\n      }\n    }\n\
        \  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 1
- match:
    aggregations.fi.buckets.0.doc_count: 4
- match:
    aggregations.fi.buckets.0.support: 0.4
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "compressor low pressure"
---
Test frequent item sets exclude:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\n\
        \            \"field\": \"error_message\",\n            \"exclude\": \"engine\
        \ overheated\"\n          }\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 3
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- match:
    aggregations.fi.buckets.1.doc_count: 3
- match:
    aggregations.fi.buckets.1.support: 0.3
---
Test frequent item sets include:
- do:
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\n\
        \            \"field\": \"error_message\",\n            \"include\": \"en.*ed\"\
        \n          }\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 3
- match:
    aggregations.fi.buckets.0.doc_count: 4
- match:
    aggregations.fi.buckets.0.support: 0.4
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "engine overheated"
---
Test frequent item sets unsupported types:
- do:
    catch: "/Field \\[geo_point\\] of type \\[geo_point\\] is not supported for aggregation\
      \ \\[frequent_item_sets\\]/"
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"},\n          {\"field\": \"geo_point\"}\n     \
        \   ]\n      }\n    }\n  }\n}\n"
    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:
    catch: "/Field \\[histogram\\] of type \\[histogram\\] is not supported for aggregation\
      \ \\[frequent_item_sets\\]/"
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"},\n          {\"field\": \"histogram\"}\n     \
        \   ]\n      }\n    }\n  }\n}\n"
    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"
---
Test frequent item sets unsupported subaggs:
- do:
    catch: "/Aggregator \\[fi\\] of type \\[frequent_item_sets\\] cannot accept sub-aggregations/"
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"}\n        ]\n      },\n    \"aggs\": {\n      \"\
        sum\": {\n        \"sum\": {\n          \"field\": \"some_field\"\n      \
        \  }\n      }\n    }\n  }\n  }\n}\n"
    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"
---
Test deprecated frequent items:
- skip:
    features:
    - "allowed_warnings"
- do:
    allowed_warnings:
    - "Deprecated field [frequent_items] used, expected [frequent_item_sets] instead"
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_items\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"}\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 4
- match:
    aggregations.fi.buckets.0.doc_count: 5
- match:
    aggregations.fi.buckets.0.support: 0.5
- match:
    aggregations.fi.buckets.0.key.error_message:
    - "compressor low pressure"
- match:
    aggregations.fi.buckets.1.doc_count: 4
- match:
    aggregations.fi.buckets.1.support: 0.4
- match:
    aggregations.fi.buckets.1.key.error_message:
    - "engine overheated"
---
Test frequent items on empty index:
- do:
    search:
      index: "unavailable-data"
      body: "{\n  \"size\": 0,\n  \"aggs\": {\n    \"fi\": {\n      \"frequent_item_sets\"\
        : {\n        \"minimum_set_size\": 3,\n        \"minimum_support\": 0.3,\n\
        \        \"fields\": [\n          {\"field\": \"features\"},\n          {\"\
        field\": \"error_message\"}\n        ]\n      }\n    }\n  }\n}\n"
    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"
- length:
    aggregations.fi.buckets: 0
