### Elasticsearch Version

8.5.0

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Linux 9b4c50a443c1 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

### Problem Description

In 8.5, _nodes/stats returns a failure message if the node has closed indices. In previous versions, it works.
Please see steps to reproduce.

### Steps to Reproduce

```
$ curl -XPUT http://localhost:9200/test_index
$ curl http://localhost:9200/_nodes/stats  # <- it works
$ curl -XPOST http://localhost:9200/test_index/_close
$ curl http://localhost:9200/_nodes/stats
{
  "_nodes": {
    "total": 1,
    "successful": 0,
    "failed": 1,
    "failures": [
      {
        "type": "failed_node_exception",
        "reason": "Failed node [...]",
        "node_id": "...",
        "caused_by": {
          "type": "null_pointer_exception",
          "reason": "Cannot invoke \"org.elasticsearch.index.mapper.MapperService.mappingLookup()\" because the return value of \"org.elasticsearch.index.IndexService.mapperService()\" is null"
        }
      }
    ]
  },
  "cluster_name": "...",
  "nodes": {}
}
```

### Logs (if relevant)

_No response_
server/src/test/java/org/elasticsearch/index/IndexServiceTests.java
public void testAsyncTranslogTrimActuallyWorks() throws Exception {
        Settings settings = Settings.builder()
            .put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "100ms") 
            .build();
        IndexService indexService = createIndex("test", settings);
        ensureGreen("test");
        assertTrue(indexService.getTrimTranslogTask().mustReschedule());
        client().prepareIndex("test").setId("1").setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
        client().admin().indices().prepareFlush("test").get();
        IndexShard shard = indexService.getShard(0);
        assertBusy(() -> assertThat(IndexShardTestCase.getTranslog(shard).totalOperations(), equalTo(0)));
    }
    public void testAsyncTranslogTrimTaskOnClosedIndex() throws Exception {
        final String indexName = "test";
        IndexService indexService = createIndex(
            indexName,
            Settings.builder().put(TRANSLOG_RETENTION_CHECK_INTERVAL_SETTING.getKey(), "100ms").build()
        );
        Translog translog = IndexShardTestCase.getTranslog(indexService.getShard(0));
        int translogOps = 0;
        final int numDocs = scaledRandomIntBetween(10, 100);
        for (int i = 0; i < numDocs; i++) {
            client().prepareIndex().setIndex(indexName).setId(String.valueOf(i)).setSource("{\"foo\": \"bar\"}", XContentType.JSON).get();
            translogOps++;
            if (randomBoolean()) {
                client().admin().indices().prepareFlush(indexName).get();
                if (indexService.getIndexSettings().isSoftDeleteEnabled()) {
                    translogOps = 0;
                }
            }