### Description

For certain mappings the following query:
```
POST _query?error_trace
{
  “query”: “”"
  from * [metadata _index] | limit 10000
  “”"
}
```

triggers a CCE:
```
{ "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)",
        "stack_trace": """org.elasticsearch.ElasticsearchException$1: class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)

Caused by: java.lang.ClassCastException: class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class 
org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)
	at org.elasticsearch.xpack.ql.index.IndexResolver.buildIndices(IndexResolver.java:771)
	at org.elasticsearch.xpack.ql.index.IndexResolver.mergedMappings(IndexResolver.java:466)
	at org.elasticsearch.xpack.ql.index.IndexResolver.lambda$resolveAsMergedMapping$8(IndexResolver.java:381)
	at org.elasticsearch.server@8.11.0/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:236)
	... 21 more
```
x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java
ActionListener<List<EsIndex>> listener
    ) {
        FieldCapabilitiesRequest fieldRequest = createFieldCapsRequest(indexWildcard, ALL_FIELDS, includeFrozen, runtimeMappings);
        client.fieldCaps(fieldRequest, listener.delegateFailureAndWrap((delegate, response) -> {
            client.admin().indices().getAliases(createGetAliasesRequest(response, includeFrozen), wrap(aliases -> {
                delegate.onResponse(separateMappings(typeRegistry, javaRegex, response, aliases.getAliases()));
            }, ex -> {
                if (ex instanceof IndexNotFoundException || ex instanceof ElasticsearchSecurityException) {
                    delegate.onResponse(separateMappings(typeRegistry, javaRegex, response, null));
                } else {
                    delegate.onFailure(ex);
                }
            }));
        }));
    }
    private static GetAliasesRequest createGetAliasesRequest(FieldCapabilitiesResponse response, boolean includeFrozen) {
        return new GetAliasesRequest().local(true)
            .aliases("*")
            .indices(response.getIndices())
            .indicesOptions(includeFrozen ? FIELD_CAPS_FROZEN_INDICES_OPTIONS : FIELD_CAPS_INDICES_OPTIONS);
    }
    public static List<EsIndex> separateMappings(
        DataTypeRegistry typeRegistry,
        String javaRegex,
        FieldCapabilitiesResponse fieldCaps,
        Map<String, List<AliasMetadata>> aliases
    ) {
        return buildIndices(typeRegistry, javaRegex, fieldCaps, aliases, Function.identity(), (s, cap) -> null, null);
    }
    private static class Fields {