**Build scan:**
https://gradle-enterprise.elastic.co/s/7vcre2by7feoe/tests/:server:internalClusterTest/org.elasticsearch.search.aggregations.bucket.SignificantTermsSignificanceScoreIT/testScriptScore

**Reproduction line:**
```
./gradlew ':server:internalClusterTest' --tests "org.elasticsearch.search.aggregations.bucket.SignificantTermsSignificanceScoreIT.testScriptScore" -Dtests.seed=3AF8B75C5D0AD4EA -Dtests.locale=es-PR -Dtests.timezone=EAT -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.search.aggregations.bucket.SignificantTermsSignificanceScoreIT&tests.test=testScriptScore

**Failure excerpt:**
```
java.lang.Exception: Test abandoned because suite timeout was reached.

  at __randomizedtesting.SeedInfo.seed([3AF8B75C5D0AD4EA]:0)

```
server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificanceLookup.java
if (contextFiltered != matchAllDocsQuery) {
                this.backgroundFilter = contextFiltered;
            } else {
                this.backgroundFilter = null;
            }
        } else {
            Query contextFiltered = context.filterQuery(backgroundQuery);
            this.backgroundFilter = contextFiltered;
        }
        /*
         * We need to use a superset size that includes deleted docs or we
         * could end up blowing up with bad statistics that cause us to blow
         * up later on.
         */
        IndexSearcher searcher = context.searcher();
        supersetNumDocs = this.backgroundFilter == null ? searcher.getIndexReader().maxDoc() : searcher.count(this.backgroundFilter);
    }
    /**
     * Get the number of docs in the superset.
     */
    long supersetSize() {
        return supersetNumDocs;
    }
    /**
     * Get the background frequency of a {@link BytesRef} term.
     */
    BackgroundFrequencyForBytes bytesLookup(BigArrays bigArrays, CardinalityUpperBound cardinality) {
        if (cardinality == CardinalityUpperBound.ONE) {
            return new BackgroundFrequencyForBytes() {
                @Override