### 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
"The nested depth of the query exceeds the maximum nested depth for queries set in ["
                                + INDICES_MAX_NESTED_DEPTH_SETTING.getKey()
                                + "]"
                        );
                    }
                }
                T namedObject = getXContentRegistry().parseNamedObject(categoryClass, name, this, context);
                if (categoryClass.equals(QueryBuilder.class)) {
                    queryNameConsumer.accept(name);
                    nestedDepth--;
                }
                return namedObject;
            }
        };
        return parseInnerQueryBuilder(parserWrapper);
    }
    /**
     * Parses an inner query. To be called by query implementations that support inner queries.
     */
    protected static QueryBuilder parseInnerQueryBuilder(XContentParser parser) throws IOException {
        if (parser.currentToken() != XContentParser.Token.START_OBJECT) {
            if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
                throw new ParsingException(parser.getTokenLocation(), "[_na] query malformed, must start with start_object");
            }
        }
        if (parser.nextToken() == XContentParser.Token.END_OBJECT) {
            
            throw new IllegalArgumentException("query malformed, empty clause found at [" + parser.getTokenLocation() + "]");
        }
        if (parser.currentToken() != XContentParser.Token.FIELD_NAME) {