### Elasticsearch Version

latest

### Installed Plugins

_No response_

### Java Version

18.0.1.1

### OS Version

Linux 5.17.6-1-MANJARO

### Problem Description

We created a `hasData` service which utilizes the `resolve_index` api to check whether ES data exists. When making a call to `internal/index-pattern-management/resolve_index` to query whether data exists or not, in certain scenarios it fails with a 500 Internal Server Error.

The ES error being - 

> security_exception: [security_exception] Reason: action [indices:admin/resolve/index] is unauthorized for user [test_user] with roles [test_dashboard_user,reporting_user], this
action is granted by the index privileges [view_index_metadata,manage,all]

The scenarios being:
Scenario one:
1. There are 3 indices
2. User has `read` access to 1 of the indices, but not to the other two
3. The call fails with a 500 Internal Server Error. The user should be able to see the index they have access to.

Scenario two:
1. This refers to a scenario where the user has `read` access to the index, but `no view_index_metadata` privileges.

Original issue ticket in Kibana for reference - [#132478](https://github.com/elastic/kibana/issues/132478)

### Steps to Reproduce

The user has `read` access to the index, but `no view_index_metadata` privileges.
The api fails with a 500 due to the missing permissions.

### Logs (if relevant)

security_exception: [security_exception] Reason: action [indices:admin/resolve/index] is unauthorized for user [test_user] with roles [test_dashboard_user,reporting_user], this
action is granted by the index privileges [view_index_metadata,manage,all]
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/IndexPrivilege.java
private static final Automaton MANAGE_ILM_AUTOMATON = patterns("indices:admin/ilm/*");
    private static final Automaton MAINTENANCE_AUTOMATON = patterns(
        "indices:admin/refresh*",
        "indices:admin/flush*",
        "indices:admin/synced_flush",
        "indices:admin/forcemerge*"
    );
    private static final Automaton AUTO_CONFIGURE_AUTOMATON = patterns(AutoPutMappingAction.NAME, AutoCreateAction.NAME);
    public static final IndexPrivilege NONE = new IndexPrivilege("none", Automatons.EMPTY);
    public static final IndexPrivilege ALL = new IndexPrivilege("all", ALL_AUTOMATON);
    public static final IndexPrivilege READ = new IndexPrivilege("read", READ_AUTOMATON);
    public static final IndexPrivilege READ_CROSS_CLUSTER = new IndexPrivilege("read_cross_cluster", READ_CROSS_CLUSTER_AUTOMATON);
    public static final IndexPrivilege CREATE = new IndexPrivilege("create", CREATE_AUTOMATON);
    public static final IndexPrivilege INDEX = new IndexPrivilege("index", INDEX_AUTOMATON);
    public static final IndexPrivilege DELETE = new IndexPrivilege("delete", DELETE_AUTOMATON);
    public static final IndexPrivilege WRITE = new IndexPrivilege("write", WRITE_AUTOMATON);
    public static final IndexPrivilege CREATE_DOC = new IndexPrivilege("create_doc", CREATE_DOC_AUTOMATON);
    public static final IndexPrivilege MONITOR = new IndexPrivilege("monitor", MONITOR_AUTOMATON);
    public static final IndexPrivilege MANAGE = new IndexPrivilege("manage", MANAGE_AUTOMATON);
    public static final IndexPrivilege DELETE_INDEX = new IndexPrivilege("delete_index", DELETE_INDEX_AUTOMATON);
    public static final IndexPrivilege CREATE_INDEX = new IndexPrivilege("create_index", CREATE_INDEX_AUTOMATON);
    public static final IndexPrivilege VIEW_METADATA = new IndexPrivilege("view_index_metadata", VIEW_METADATA_AUTOMATON);
    public static final IndexPrivilege MANAGE_FOLLOW_INDEX = new IndexPrivilege("manage_follow_index", MANAGE_FOLLOW_INDEX_AUTOMATON);
    public static final IndexPrivilege MANAGE_LEADER_INDEX = new IndexPrivilege("manage_leader_index", MANAGE_LEADER_INDEX_AUTOMATON);
    public static final IndexPrivilege MANAGE_ILM = new IndexPrivilege("manage_ilm", MANAGE_ILM_AUTOMATON);
    public static final IndexPrivilege MAINTENANCE = new IndexPrivilege("maintenance", MAINTENANCE_AUTOMATON);
    public static final IndexPrivilege AUTO_CONFIGURE = new IndexPrivilege("auto_configure", AUTO_CONFIGURE_AUTOMATON);
    private static final Map<String, IndexPrivilege> VALUES = sortByAccessLevel(
        Map.ofEntries(
            entry("none", NONE),