### 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
}
    /**
     * Adds {@code boost} and {@code query_name} parsing to the
     * {@link AbstractObjectParser} passed in. All query builders except
     * {@link MatchAllQueryBuilder} and {@link MatchNoneQueryBuilder} support these fields so they
     * should use this method.
     */
    protected static void declareStandardFields(AbstractObjectParser<? extends QueryBuilder, ?> parser) {
        parser.declareFloat(QueryBuilder::boost, AbstractQueryBuilder.BOOST_FIELD);
        parser.declareString(QueryBuilder::queryName, AbstractQueryBuilder.NAME_FIELD);
    }
    /**
     * Set the maximum nested depth of bool queries.
     * Default value is 20.
     */
    public static void setMaxNestedDepth(int maxNestedDepth) {
        if (maxNestedDepth < 1) {
            throw new IllegalArgumentException("maxNestedDepth must be >= 1");
        }
        AbstractQueryBuilder.maxNestedDepth = maxNestedDepth;
    }
    public static int getMaxNestedDepth() {
        return maxNestedDepth;
    }
    @Override
    public final String toString() {
        return Strings.toString(this, true, true);
    }
}