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
int maxResultWindow = randomIntBetween(50, 100);
        int maxRescoreWindow = randomIntBetween(50, 100);
        int maxSlicesPerScroll = randomIntBetween(50, 100);
        Settings settings = indexSettings(IndexVersion.current(), 2, 1).put("index.max_result_window", maxResultWindow)
            .put("index.max_slices_per_scroll", maxSlicesPerScroll)
            .put("index.max_rescore_window", maxRescoreWindow)
            .build();
        IndexService indexService = mock(IndexService.class);
        IndexCache indexCache = mock(IndexCache.class);
        QueryCache queryCache = mock(QueryCache.class);
        when(indexCache.query()).thenReturn(queryCache);
        when(indexService.cache()).thenReturn(indexCache);
        SearchExecutionContext searchExecutionContext = mock(SearchExecutionContext.class);
        when(indexService.newSearchExecutionContext(eq(shardId.id()), eq(shardId.id()), any(), any(), nullable(String.class), any()))
            .thenReturn(searchExecutionContext);
        MapperService mapperService = mock(MapperService.class);
        when(mapperService.hasNested()).thenReturn(randomBoolean());
        when(indexService.mapperService()).thenReturn(mapperService);
        IndexMetadata indexMetadata = IndexMetadata.builder("index").settings(settings).build();
        IndexSettings indexSettings = new IndexSettings(indexMetadata, Settings.EMPTY);
        when(indexService.getIndexSettings()).thenReturn(indexSettings);
        when(mapperService.getIndexSettings()).thenReturn(indexSettings);
        when(searchExecutionContext.getIndexSettings()).thenReturn(indexSettings);
        when(searchExecutionContext.indexVersionCreated()).thenReturn(indexSettings.getIndexVersionCreated());
        try (Directory dir = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), dir)) {
            final Supplier<Engine.SearcherSupplier> searcherSupplier = () -> new Engine.SearcherSupplier(Function.identity()) {
                @Override
                protected void doClose() {}
                @Override
                protected Engine.Searcher acquireSearcherInternal(String source) {