### 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
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */
package org.elasticsearch.xpack.core.termsenum.action;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ValidateActions;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
/**
 * A request to gather terms for a given field matching a string prefix
 */
public class TermsEnumRequest extends BroadcastRequest<TermsEnumRequest> implements ToXContentObject {