### 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
IOException {
        List<Query> queries = new ArrayList<>(queryBuilders.size());
        for (QueryBuilder queryBuilder : queryBuilders) {
            Query query = queryBuilder.rewrite(context).toQuery(context);
            if (query != null) {
                queries.add(query);
            }
        }
        return queries;
    }
    @Override
    public String getName() {
        
        return getWriteableName();
    }
    protected static void writeQueries(StreamOutput out, List<? extends QueryBuilder> queries) throws IOException {
        out.writeVInt(queries.size());
        for (QueryBuilder query : queries) {
            out.writeNamedWriteable(query);
        }
    }
    protected static List<QueryBuilder> readQueries(StreamInput in) throws IOException {
        return in.readNamedWriteableCollectionAsList(QueryBuilder.class);
    }
    @Override
    public final QueryBuilder rewrite(QueryRewriteContext queryRewriteContext) throws IOException {
        QueryBuilder rewritten = doRewrite(queryRewriteContext);
        if (rewritten == this) {
            return rewritten;
        }