---
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:
            product:
              type: "keyword"
            cost:
              type: "integer"
            time:
              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"
---
Test setting results field is invalid:
- do:
    catch: "/action_request_validation_exception/"
    search:
      index: "store"
      body: "{\n  \"size\": 0,\n  \"query\": { \"match_all\" : { } },\n  \"aggs\"\
        : {\n    \"good\": {\n      \"terms\": {\n        \"field\": \"product\",\n\
        \        \"size\": 10\n      },\n      \"aggs\": {\n        \"avg_cost_agg\"\
        : {\n          \"avg\": {\n            \"field\": \"cost\"\n          }\n\
        \        },\n        \"regression_agg\" : {\n          \"inference\": {\n\
        \            \"model_id\": \"a-complex-regression-model\",\n            \"\
        inference_config\": {\n              \"regression\": {\n                \"\
        results_field\": \"banana\"\n              }\n            },\n           \
        \ \"buckets_path\": {\n              \"cost\" : \"avg_cost_agg\"\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"
- match:
    error.root_cause.0.type: "action_request_validation_exception"
- match:
    error.root_cause.0.reason: "Validation Failed: 1: setting option [results_field]\
      \ to [banana] is not valid for inference aggregations;"
