### 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
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = SearchRequest.DEFAULT_INDICES_OPTIONS;
    public static int DEFAULT_SIZE = 10;
    public static TimeValue DEFAULT_TIMEOUT = new TimeValue(1000);
    private String field;
    private String string = null;
    private String searchAfter = null;
    private int size = DEFAULT_SIZE;
    private boolean caseInsensitive;
    private QueryBuilder indexFilter;
    public TermsEnumRequest() {
        this(Strings.EMPTY_ARRAY);
    }
    /**
     * Constructs a new term enum request against the provided indices. No indices provided means it will
     * run against all indices.
     */
    public TermsEnumRequest(String... indices) {
        super(indices);
        indicesOptions(DEFAULT_INDICES_OPTIONS);
        timeout(DEFAULT_TIMEOUT);
    }
    public TermsEnumRequest(TermsEnumRequest clone) {
        this.field = clone.field;
        this.string = clone.string;
        this.searchAfter = clone.searchAfter;
        this.caseInsensitive = clone.caseInsensitive;
        this.size = clone.size;
        this.indexFilter = clone.indexFilter;
        indices(clone.indices);
        indicesOptions(clone.indicesOptions());