### Description

There is a hard limit on the size of terms that can be indexed in lucene.  However, we don't check this at query time, which can lead to memory issues if the term query in question is case insensitive.  Very long terms are normally a sign of user error, so we should check up-front the length of the input and throw and exception if it is greater than `IndexWriter.MAX_TERM_LENGTH`.
server/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java
}
    protected abstract void doWriteTo(StreamOutput out) throws IOException;
    @Override
    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        builder.startObject();
        doXContent(builder, params);
        builder.endObject();
        return builder;
    }
    protected abstract void doXContent(XContentBuilder builder, Params params) throws IOException;
    /**
     * Add {@code boost} and {@code query_name} to the builder.
     * @deprecated use {@link #boostAndQueryNameToXContent}
     */
    @Deprecated
    protected final void printBoostAndQueryName(XContentBuilder builder) throws IOException {
        builder.field(BOOST_FIELD.getPreferredName(), boost);
        if (queryName != null) {
            builder.field(NAME_FIELD.getPreferredName(), queryName);
        }
    }
    /**
     * Add {@code boost} and {@code query_name} to the builder.
     */
    protected final void boostAndQueryNameToXContent(XContentBuilder builder) throws IOException {
        if (boost != DEFAULT_BOOST) {
            builder.field(BOOST_FIELD.getPreferredName(), boost);
        }
        if (queryName != null) {
            builder.field(NAME_FIELD.getPreferredName(), queryName);