### CI Link

https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request+part-1/37011/

### Repro line

./gradlew 'null' --tests "org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.testQueryFiltering" -Dtests.seed=AB1022A12018B138 -Dtests.locale=fr-CA -Dtests.timezone=Asia/Amman -Druntime.java=20

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

_No response_

### Failure excerpt

java.lang.AssertionError: 
Expected: within <10.0> percent of <125.0>
     but: was <103.56692363555098>
Expected :within <10.0> percent of <125.0>
Actual   :<103.56692363555098>

	at __randomizedtesting.SeedInfo.seed([AB1022A12018B138:6F79CE6D4F544F21]:0)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
	at org.junit.Assert.assertThat(Assert.java:956)
	at org.junit.Assert.assertThat(Assert.java:923)
	at org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.lambda$testQueryFiltering$11(MedianAbsoluteDeviationAggregatorTests.java:130)
	at org.elasticsearch.search.aggregations.AggregatorTestCase.testCase(AggregatorTestCase.java:699)
	at org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.testAggregation(MedianAbsoluteDeviationAggregatorTests.java:233)
	at org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.testAggregation(MedianAbsoluteDeviationAggregatorTests.java:223)
	at org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.testQueryFiltering(MedianAbsoluteDeviationAggregatorTests.java:125)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
server/src/test/java/org/elasticsearch/search/aggregations/metrics/MedianAbsoluteDeviationAggregatorTests.java
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */
package org.elasticsearch.search.aggregations.metrics;
import org.apache.lucene.document.IntPoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.SortedNumericDocValuesField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.NumberFieldMapper;
import org.elasticsearch.script.MockScriptEngine;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptEngine;
import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptType;