**Kibana version:**

8.4.0-SNAPSHOT

**Elasticsearch version:**

8.4.0-SNAPSHOT

**Describe the bug:**

https://github.com/elastic/elasticsearch/pull/86166 added the option for object fields in mappings to have a `subobjects : false` setting. This in turn allows fieldnames with dots to be nested inside the object, without the usual object/scalar clashes that would arise if some scalar fields have more components than others with the same prefix.

Unlike anomaly detection and transforms (see https://github.com/elastic/elasticsearch/issues/88379 and https://github.com/elastic/elasticsearch/issues/88386 for the backend problems with those), the backend of data frame analytics does appear to work with indices with `subobjects : false`.  However, the UI shows an incorrect hint when creating a data frame analytics job for a source index with metrics in a `subobjects : false` object:

<img width="1484" alt="Screenshot 2022-07-08 at 16 10 47" src="https://user-images.githubusercontent.com/7405510/178021716-f6c87391-5b36-4db6-b0c8-6450caade9d1.png">

In this case `metrics.responsetime` should _not_ be preferred to `metrics.responsetime.min` or `metrics.responsetime.max`.  All three of these fields are equally valid to use in the job.

The field caps response says they are all aggregatable:

```
{
  "indices": [
    "metrics2"
  ],
  "fields": {
    "_routing": {
      "_routing": {
        "type": "_routing",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": false
      }
    },
    "_doc_count": {
      "integer": {
        "type": "integer",
        "metadata_field": true,
        "searchable": false,
        "aggregatable": false
      }
    },
    "_index": {
      "_index": {
        "type": "_index",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_feature": {
      "_feature": {
        "type": "_feature",
        "metadata_field": true,
        "searchable": false,
        "aggregatable": false
      }
    },
    "attributes.service.category": {
      "keyword": {
        "type": "keyword",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "metrics.responsetime": {
      "double": {
        "type": "double",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "metrics.responsetime.max": {
      "double": {
        "type": "double",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "attributes.service": {
      "keyword": {
        "type": "keyword",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_tier": {
      "keyword": {
        "type": "keyword",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_ignored": {
      "_ignored": {
        "type": "_ignored",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": false
      }
    },
    "_seq_no": {
      "_seq_no": {
        "type": "_seq_no",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": true
      }
    },
    "@timestamp": {
      "date": {
        "type": "date",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_nested_path": {
      "_nested_path": {
        "type": "_nested_path",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": false
      }
    },
    "attributes.service.administrator": {
      "keyword": {
        "type": "keyword",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_data_stream_timestamp": {
      "_data_stream_timestamp": {
        "type": "_data_stream_timestamp",
        "metadata_field": true,
        "searchable": false,
        "aggregatable": false
      }
    },
    "_field_names": {
      "_field_names": {
        "type": "_field_names",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": false
      }
    },
    "metrics.responsetime.min": {
      "double": {
        "type": "double",
        "metadata_field": false,
        "searchable": true,
        "aggregatable": true
      }
    },
    "_source": {
      "_source": {
        "type": "_source",
        "metadata_field": true,
        "searchable": false,
        "aggregatable": false
      }
    },
    "attributes": {
      "object": {
        "type": "object",
        "metadata_field": false,
        "searchable": false,
        "aggregatable": false
      }
    },
    "_id": {
      "_id": {
        "type": "_id",
        "metadata_field": true,
        "searchable": true,
        "aggregatable": false
      }
    },
    "metrics": {
      "object": {
        "type": "object",
        "metadata_field": false,
        "searchable": false,
        "aggregatable": false
      }
    },
    "_version": {
      "_version": {
        "type": "_version",
        "metadata_field": true,
        "searchable": false,
        "aggregatable": true
      }
    }
  }
}
```

**Steps to reproduce:**

Paste the following into dev console:

```
PUT metrics2
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
     "properties": {
        "@timestamp": {
          "type": "date"
        },
        "metrics": {
          "subobjects": false,
          "properties": {
            "responsetime": {
              "type": "double"
            },
            "responsetime.min": {
              "type": "double"
            },
            "responsetime.max": {
              "type": "double"
            }
          }
        },
        "attributes" : {
          "subobjects": false,
          "properties": {
            "service": {
              "type": "keyword"
            },
            "service.category": {
              "type": "keyword"
            },
            "service.administrator": {
              "type": "keyword"
            }
          }
        }
     }
  }
}

PUT metrics2/_doc/1
{
  "@timestamp" : "2022-06-23T00:00:00Z",
  "attributes" : {
    "service" : "elasticsearch",
    "service.administrator" : "dave",
    "service.category" : "search engine"
  },
  "metrics" : {
    "responsetime" : 100,
    "responsetime.min" : 10,
    "responsetime.max" : 900
  }
}

PUT metrics2/_doc/2
{
  "@timestamp" : "2022-06-30T00:00:00Z",
  "attributes" : {
    "service" : "elasticsearch",
    "service.administrator" : "dave",
    "service.category" : "search engine"
  },
  "metrics" : {
    "responsetime" : 100,
    "responsetime.min" : 10,
    "responsetime.max" : 900
  }
}
```

(The `subobjects: false` bits in the mappings are what makes this different to what we're used to.)

Then create a data view named `metrics2` for the `metrics2` index pattern.  Accept the default timestamp and other fields.  After creation this data view should show that the 3 metric fields are both searchable and aggregatable.

Create a data frame analytics job on the `metrics2` data view.  Hopefully you will see the incorrect suggestions from the red box in the screenshot above.

**Expected behavior:**

When `subobjects: false` is in the index mappings for an object we should consider all metric fields under that object to be equally valid candidates for inclusion in a data frame analytics job.
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetectorTests.java
FieldSelection.included("your_field2", Collections.singleton("float"), false, FieldSelection.FeatureType.NUMERICAL)
        );
    }
    public void testDetect_GivenIncludedFieldHasUnsupportedType() {
        FieldCapabilitiesResponse fieldCapabilities = new MockFieldCapsResponseBuilder().addAggregatableField("my_field1_nope", "float")
            .addAggregatableField("my_field1", "float")
            .addAggregatableField("your_field2", "float")
            .addAggregatableField("your_keyword", "keyword")
            .build();
        analyzedFields = FetchSourceContext.of(true, new String[] { "your*", "my_*" }, new String[] { "*nope" });
        ExtractedFieldsDetector extractedFieldsDetector = new ExtractedFieldsDetector(
            buildOutlierDetectionConfig(),
            100,
            fieldCapabilities,
            Collections.emptyMap()
        );
        ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, extractedFieldsDetector::detect);
        assertThat(
            e.getMessage(),
            equalTo(
                "field [your_keyword] has unsupported type [keyword]. "
                    + "Supported types are [boolean, byte, double, float, half_float, integer, long, scaled_float, short, unsigned_long]."
            )
        );
    }
    public void testDetect_GivenNotIncludedFieldHasUnsupportedType() {
        FieldCapabilitiesResponse fieldCapabilities = new MockFieldCapsResponseBuilder().addAggregatableField("numeric", "float")
            .addAggregatableField("categorical", "keyword")
            .build();
        analyzedFields = FetchSourceContext.of(true, new String[] { "numeric" }, null);