### 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/test/java/org/elasticsearch/index/query/TermQueryBuilderTests.java
assertEquals(query, termQuery(mapper, queryBuilder.value(), queryBuilder.caseInsensitive()));
        } else {
            assertThat(query, instanceOf(MatchNoDocsQuery.class));
        }
    }
    private Query termQuery(MappedFieldType mapper, Object value, boolean caseInsensitive) {
        if (caseInsensitive) {
            return mapper.termQueryCaseInsensitive(value, FieldTypeTestCase.MOCK_CONTEXT);
        }
        return mapper.termQuery(value, FieldTypeTestCase.MOCK_CONTEXT);
    }
    public void testTermArray() throws IOException {
        String queryAsString = """
            {
                "term": {
                    "age": [34, 35]
                }
            }""";
        ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(queryAsString));
        assertEquals("[term] query does not support array of values", e.getMessage());
    }
    public void testFromJson() throws IOException {
        String json = """
            {
              "term" : {
                "exact_value" : {
                  "value" : "Quick Foxes!",
                  "case_insensitive" : true
                }
              }