### CI Link

https://gradle-enterprise.elastic.co/s/b57j3vuz7qk2q/tests/:server:test/org.elasticsearch.index.query.SpanContainingQueryBuilderTests/testMaxNestedDepth

### Repro line

`gradlew ':server:test' --tests "org.elasticsearch.index.query.SpanContainingQueryBuilderTests.testMaxNestedDepth" -Dtests.seed=FCAC1620A8E66666 -Dtests.locale=de-AT -Dtests.timezone=America/Shiprock -Druntime.java=19`

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.timeZoneId=Europe/Berlin&tests.container=org.elasticsearch.index.query.SpanContainingQueryBuilderTests&tests.test=testMaxNestedDepth#

### Failure excerpt

```
java.lang.OutOfMemoryError: Java heap space	
	at __randomizedtesting.SeedInfo.seed([FCAC1620A8E66666:445BD40EBC1BAFC9]:0)	
		•••
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:88)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:89)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanContainingQueryBuilder.doXContent(SpanContainingQueryBuilder.java:87)	
```
server/src/test/java/org/elasticsearch/search/SearchModuleTests.java
"script",
        "script_score",
        "simple_query_string",
        "span_containing",
        "span_field_masking",
        "span_first",
        "span_gap",
        "span_multi",
        "span_near",
        "span_not",
        "span_or",
        "span_term",
        "span_within",
        "term",
        "terms",
        "terms_set",
        "wildcard",
        "wrapper",
        "distance_feature" };
    
    private static final String[] DEPRECATED_QUERIES = new String[] { "field_masking_span", "geo_polygon" };
    private static final String[] REST_COMPATIBLE_QUERIES = new String[] {
        TypeQueryV7Builder.NAME_V7.getPreferredName(),
        CommonTermsQueryBuilder.NAME_V7.getPreferredName() };
    private static final String[] REST_COMPATIBLE_AGGREGATIONS = new String[] {
        MovAvgPipelineAggregationBuilder.NAME_V7.getPreferredName() };
    /**
     * Dummy test {@link AggregationBuilder} used to test registering aggregation builders.
     */
    private static class TestAggregationBuilder extends ValuesSourceAggregationBuilder<TestAggregationBuilder> {