### Elasticsearch Version

8.3.0

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

arm64

### Problem Description

When using the `_terms_enum` API, if remote clusters return failures, but the local cluster doesn't, a null exception is thrown:

```
{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": "Cannot invoke \"java.util.List.add(Object)\" because \"shardFailures\" is null"
      }
    ],
    "type": "null_pointer_exception",
    "reason": "Cannot invoke \"java.util.List.add(Object)\" because \"shardFailures\" is null"
  },
  "status": 500
}
```

### Steps to Reproduce

Call the _terms_enum API with a remote cluster that will return failures, e.g. because of this bug: https://github.com/elastic/elasticsearch/issues/86187

### Logs (if relevant)

_No response_
x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java
name(),
                CoreValuesSourceType.KEYWORD,
                (dv, n) -> new ConstantKeywordDocValuesField(FieldData.toString(dv), n)
            );
        }
        @Override
        public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
            if (format != null) {
                throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
            }
            return value == null ? (lookup, ignoredValues) -> List.of() : (lookup, ignoredValues) -> List.of(value);
        }
        @Override
        public TermsEnum getTerms(boolean caseInsensitive, String string, SearchExecutionContext queryShardContext, String searchAfter) {
            boolean matches = caseInsensitive
                ? value.toLowerCase(Locale.ROOT).startsWith(string.toLowerCase(Locale.ROOT))
                : value.startsWith(string);
            if (matches == false) {
                return null;
            }
            if (searchAfter != null) {
                if (searchAfter.compareTo(value) >= 0) {
                    
                    return null;
                }
            }
            return new SimpleTermCountEnum(value);
        }
        @Override
        protected boolean matches(String pattern, boolean caseInsensitive, SearchExecutionContext context) {