As part of running a elastic/logging benchmark with synthetic source enabled, I noticed the following stacktrace in the Elasticsearch logs:

```
Caused by: org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: index_out_of_bounds_exception: null
        at org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$TermsDict.seekExact(Lucene90DocValuesProducer.java:1114) ~[lucene-core-9.8.0.jar:?]
        at org.apache.lucene.codecs.lucene90.Lucene90DocValuesProducer$BaseSortedDocValues.lookupOrd(Lucene90DocValuesProducer.java:982) ~[lucene-core-9.8.0.jar:?]
        at org.apache.lucene.index.SingletonSortedSetDocValues.lookupOrd(SingletonSortedSetDocValues.java:95) ~[lucene-core-9.8.0.jar:?]
        at org.elasticsearch.index.mapper.SortedSetDocValuesSyntheticFieldLoader$ImmediateDocValuesLoader.write(SortedSetDocValuesSyntheticFieldLoader.java:198) ~[elasticsea
rch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.index.mapper.SortedSetDocValuesSyntheticFieldLoader.write(SortedSetDocValuesSyntheticFieldLoader.java:125) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?
]
        at org.elasticsearch.index.mapper.ObjectMapper$SyntheticSourceFieldLoader.write(ObjectMapper.java:711) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.index.mapper.ObjectMapper$SyntheticSourceFieldLoader.write(ObjectMapper.java:711) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.index.mapper.SourceLoader$Synthetic$SyntheticLeaf.source(SourceLoader.java:126) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.lookup.SyntheticSourceProvider$SyntheticSourceLeafLoader.getSource(SyntheticSourceProvider.java:74) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?
]
        at org.elasticsearch.search.lookup.SyntheticSourceProvider.getSource(SyntheticSourceProvider.java:40) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.lookup.LeafSearchLookup.lambda$new$0(LeafSearchLookup.java:39) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.script.AbstractFieldScript.extractFromSource(AbstractFieldScript.java:106) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.script.AbstractFieldScript.emitFromSource(AbstractFieldScript.java:126) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.script.LongFieldScript$1$1.execute(LongFieldScript.java:28) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.script.AbstractFieldScript.runForDoc(AbstractFieldScript.java:158) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.runtime.AbstractLongScriptFieldQuery.matches(AbstractLongScriptFieldQuery.java:33) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.runtime.AbstractLongScriptFieldQuery.matches(AbstractLongScriptFieldQuery.java:21) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.runtime.AbstractScriptFieldQuery$1$1.matches(AbstractScriptFieldQuery.java:77) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreRange(Weight.java:295) ~[lucene-core-9.8.0.jar:?]
        at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:236) ~[lucene-core-9.8.0.jar:?]
        at org.elasticsearch.search.internal.CancellableBulkScorer.score(CancellableBulkScorer.java:45) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:38) ~[lucene-core-9.8.0.jar:?]
        at org.elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:526) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:455) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.search.internal.ContextIndexSearcher.lambda$search$4(ContextIndexSearcher.java:370) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) ~[elasticsearch-8.12.0-SNAPSHOT.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
```

I don't have more information yet. I will update this issue when I know more.
server/src/test/java/org/elasticsearch/search/DefaultSearchContextTests.java
false,
                    null,
                    randomFrom(SearchService.ResultsType.values()),
                    randomBoolean(),
                    randomInt()
                )
            ) {
                context4.sliceBuilder(new SliceBuilder(1, 2)).parsedQuery(parsedQuery).preProcess();
                Query query1 = context4.query();
                context4.sliceBuilder(new SliceBuilder(0, 2)).parsedQuery(parsedQuery).preProcess();
                Query query2 = context4.query();
                assertTrue(query1 instanceof MatchNoDocsQuery || query2 instanceof MatchNoDocsQuery);
                readerContext.close();
                threadPool.shutdown();
            }
        }
    }
    public void testClearQueryCancellationsOnClose() throws IOException {
        TimeValue timeout = new TimeValue(randomIntBetween(1, 100));
        ShardSearchRequest shardSearchRequest = mock(ShardSearchRequest.class);
        when(shardSearchRequest.searchType()).thenReturn(SearchType.DEFAULT);
        ShardId shardId = new ShardId("index", UUID.randomUUID().toString(), 1);
        when(shardSearchRequest.shardId()).thenReturn(shardId);
        ThreadPool threadPool = new TestThreadPool(this.getClass().getName());
        IndexShard indexShard = mock(IndexShard.class);
        when(indexShard.getThreadPool()).thenReturn(threadPool);
        IndexService indexService = mock(IndexService.class);
        try (Directory dir = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), dir)) {
            final Engine.SearcherSupplier searcherSupplier = new Engine.SearcherSupplier(Function.identity()) {
                @Override