### CI Link

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

### Repro line

`gradlew ':server:test' --tests "org.elasticsearch.index.query.SpanNotQueryBuilderTests.testMaxNestedDepth" -Dtests.seed=FCAC1620A8E66666 -Dtests.locale=hu -Dtests.timezone=Etc/GMT+11 -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.SpanNotQueryBuilderTests&tests.test=testMaxNestedDepth#

### Failure excerpt

```
java.lang.OutOfMemoryError: Java heap space	
	at __randomizedtesting.SeedInfo.seed([FCAC1620A8E66666:445BD40EBC1BAFC9]:0)	
		•••
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:145)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:148)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:148)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:148)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:146)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:148)	
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:80)	
	at org.elasticsearch.index.query.SpanNotQueryBuilder.doXContent(SpanNotQueryBuilder.java:148)
```
test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java
.append((int) left.charAt(i))
                    .append(" vs.")
                    .append((int) right.charAt(i))
                    .append(']');
                return builder.toString();
            }
        }
        if (left.length() != right.length()) {
            int leftEnd = Math.max(size, left.length()) - 1;
            int rightEnd = Math.max(size, right.length()) - 1;
            builder.append(">> ")
                .append("until offset: ")
                .append(size)
                .append(" [")
                .append(left.charAt(leftEnd))
                .append(" vs.")
                .append(right.charAt(rightEnd))
                .append("] [")
                .append((int) left.charAt(leftEnd))
                .append(" vs.")
                .append((int) right.charAt(rightEnd))
                .append(']');
            return builder.toString();
        }
        return "";
    }
    /**
     * This test ensures that queries that need to be rewritten have dedicated tests.
     * These queries must override this method accordingly.
     */