### Elasticsearch Version

8.8

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

all

### Problem Description

`_terms_enum` queries against a `keyword` field build automata out of their prefix string, to be intersected with the terms dictionary on the relevant field.  We don't have a limit on the size of this prefix, meaning that if somebody (either accidentally or maliciously) passes a very large string here, we can run out of memory.

### Steps to Reproduce

Send a very large string as part of a `_terms_enum` request against a keyword field.

### Logs (if relevant)

_No response_
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/termsenum/action/TermsEnumRequest.java
+ caseInsensitive
            + " indexFilter = "
            + indexFilter
            + " searchAfter["
            + searchAfter
            + "]";
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TermsEnumRequest that = (TermsEnumRequest) o;
        return size == that.size
            && caseInsensitive == that.caseInsensitive
            && Objects.equals(field, that.field)
            && Objects.equals(string, that.string)
            && Objects.equals(searchAfter, that.searchAfter)
            && Objects.equals(indexFilter, that.indexFilter)
            && Arrays.equals(indices, that.indices)
            && Objects.equals(indicesOptions(), that.indicesOptions())
            && Objects.equals(timeout(), that.timeout());
    }
    @Override
    public int hashCode() {
        int result = Objects.hash(field, string, searchAfter, size, caseInsensitive, indexFilter, indicesOptions(), timeout());
        result = 31 * result + Arrays.hashCode(indices);
        return result;
    }
}