When using the terms enum API on a constant keyword field, an error is returned complaining about a non-null value.

Request:

```
POST /metrics-endpoint.policy-default/_terms_enum
{
  "field": "data_stream.type"
}
```

Response:

```
#! Your license will expire in [5] days. Contact your administrator or update your license for continued use of features
#! Your license will expire in [6] days. Contact your administrator or update your license for continued use of features
{
  "_shards" : {
    "total" : 8,
    "successful" : 4,
    "failed" : 4,
    "failures" : [
      {
        "shard" : 0,
        "index" : ".ds-metrics-endpoint.policy-default-2022.04.04-000001",
        "status" : "INTERNAL_SERVER_ERROR",
        "reason" : {
          "type" : "broadcast_shard_operation_failed_exception",
          "reason" : """java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "this.value" is null
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.getTerms(ConstantKeywordFieldMapper.java:156)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.dataNodeOperation(TransportTermsEnumAction.java:351)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.lambda$asyncNodeOperation$0(TransportTermsEnumAction.java:712)
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
""",
          "index_uuid" : "uOdQ_uBRRLeq5-OAJAwGrg",
          "shard" : "0",
          "index" : ".ds-metrics-endpoint.policy-default-2022.04.04-000001"
        }
      },
      {
        "shard" : 0,
        "index" : ".ds-metrics-endpoint.policy-default-2022.04.07-000002",
        "status" : "INTERNAL_SERVER_ERROR",
        "reason" : {
          "type" : "broadcast_shard_operation_failed_exception",
          "reason" : """java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "this.value" is null
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.getTerms(ConstantKeywordFieldMapper.java:156)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.dataNodeOperation(TransportTermsEnumAction.java:351)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.lambda$asyncNodeOperation$0(TransportTermsEnumAction.java:712)
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
""",
          "index_uuid" : "qBOOM6CXRpuK0budYXBUnQ",
          "shard" : "0",
          "index" : ".ds-metrics-endpoint.policy-default-2022.04.07-000002"
        }
      },
      {
        "shard" : 0,
        "index" : ".ds-metrics-endpoint.policy-default-2022.04.22-000007",
        "status" : "INTERNAL_SERVER_ERROR",
        "reason" : {
          "type" : "broadcast_shard_operation_failed_exception",
          "reason" : """java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "this.value" is null
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.getTerms(ConstantKeywordFieldMapper.java:156)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.dataNodeOperation(TransportTermsEnumAction.java:351)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.lambda$asyncNodeOperation$0(TransportTermsEnumAction.java:712)
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
""",
          "index_uuid" : "e8KIwULjSsSn3NGdm7tuPw",
          "shard" : "0",
          "index" : ".ds-metrics-endpoint.policy-default-2022.04.22-000007"
        }
      },
      {
        "shard" : 0,
        "index" : ".ds-metrics-endpoint.policy-default-2022.04.25-000008",
        "status" : "INTERNAL_SERVER_ERROR",
        "reason" : {
          "type" : "broadcast_shard_operation_failed_exception",
          "reason" : """java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "this.value" is null
	at org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper$ConstantKeywordFieldType.getTerms(ConstantKeywordFieldMapper.java:156)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.dataNodeOperation(TransportTermsEnumAction.java:351)
	at org.elasticsearch.xpack.core.termsenum.action.TransportTermsEnumAction.lambda$asyncNodeOperation$0(TransportTermsEnumAction.java:712)
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:47)
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
""",
          "index_uuid" : "bDskzrgwQbG35K389_yyKA",
          "shard" : "0",
          "index" : ".ds-metrics-endpoint.policy-default-2022.04.25-000008"
        }
      }
    ]
  },
  "terms" : [
    "metrics"
  ],
  "complete" : false
}
```
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) {