瀏覽代碼

Delete deprecated getValues from ScriptDocValues (#36183)

* Adds deprecation logging to ScriptDocValues#getValues.

First commit addressing issue #22919.

`ScriptDocValues#getValues` was added for backwards compatibility but no
longer needed. Scripts using the syntax `doc['foo'].values` when
`doc['foo']` is a list should be using `doc['foo']` instead.

* Fixes two build errors in #34279

* Removes unused import in ScriptDocValuesDatesTest
* Removes used of `.values` in example in diversified-sampler-aggregation.asciidoc

* Removes use of .values from painless test.

Part of #34279

* Updates tests to use `doc[foo]` syntax rather than `doc[foo].values`.

* Removes use of `getValues()` and replaces use of `doc[foo].values` with `doc[foo]`.

* Indentation fix.

* Remove unnecessary list construction at previous `getValues()` callsite in ScriptDocValues.GeoPoints.

* Update migration doc and add link to `getValue` in ScriptDocValues javadoc.

* Fix compile

* Fix javadoc issue

* Removes ScriptDocValues#getValues usage from painless whitelist.
Jeff Hajewski 6 年之前
父節點
當前提交
f1f3b28f5c

+ 6 - 0
docs/reference/migration/migrate_7_0/scripting.asciidoc

@@ -29,3 +29,9 @@ To check if a document is missing a value, you can use
 Malformed scripts, either in search templates, ingest pipelines or search 
 requests, return `400 - Bad request` while they would previously return
 `500 - Internal Server Error`. This also applies for stored scripts.
+
+[float]
+==== getValues() removed
+
+The `ScriptDocValues#getValues()` method is deprecated in 6.6 and will
+be removed in 7.0. Use `doc["foo"]` in place of `doc["foo"].values`.

+ 1 - 9
modules/lang-painless/src/main/resources/org/elasticsearch/painless/spi/org.elasticsearch.txt

@@ -67,13 +67,11 @@ class org.elasticsearch.common.geo.GeoPoint {
 class org.elasticsearch.index.fielddata.ScriptDocValues$Strings {
   String get(int)
   String getValue()
-  List getValues()
 }
 
 class org.elasticsearch.index.fielddata.ScriptDocValues$Longs {
   Long get(int)
   long getValue()
-  List getValues()
 }
 
 class org.elasticsearch.script.JodaCompatibleZonedDateTime {
@@ -163,19 +161,16 @@ class org.elasticsearch.script.JodaCompatibleZonedDateTime {
 class org.elasticsearch.index.fielddata.ScriptDocValues$Dates {
   JodaCompatibleZonedDateTime get(int)
   JodaCompatibleZonedDateTime getValue()
-  List getValues()
 }
 
 class org.elasticsearch.index.fielddata.ScriptDocValues$Doubles {
   Double get(int)
   double getValue()
-  List getValues()
 }
 
 class org.elasticsearch.index.fielddata.ScriptDocValues$GeoPoints {
   org.elasticsearch.common.geo.GeoPoint get(int)
   org.elasticsearch.common.geo.GeoPoint getValue()
-  List getValues()
   double getLat()
   double getLon()
   double[] getLats()
@@ -193,13 +188,11 @@ class org.elasticsearch.index.fielddata.ScriptDocValues$GeoPoints {
 class org.elasticsearch.index.fielddata.ScriptDocValues$Booleans {
   Boolean get(int)
   boolean getValue()
-  List getValues()
 }
 
 class org.elasticsearch.index.fielddata.ScriptDocValues$BytesRefs {
   BytesRef get(int)
   BytesRef getValue()
-  List getValues()
 }
 
 class org.apache.lucene.util.BytesRef {
@@ -213,7 +206,6 @@ class org.apache.lucene.util.BytesRef {
 class org.elasticsearch.index.mapper.IpFieldMapper$IpFieldType$IpScriptDocValues {
   String get(int)
   String getValue()
-  List getValues()
 }
 
 class org.elasticsearch.search.lookup.FieldLookup {
@@ -268,4 +260,4 @@ static_import {
   int staticAddIntsTest(int, int) from_class org.elasticsearch.painless.StaticTest
   float staticAddFloatsTest(float, float) from_class org.elasticsearch.painless.FeatureTest
   int testAddWithState(int, int, int, double) bound_to org.elasticsearch.painless.BindingTest
-}
+}

+ 7 - 83
server/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.index.fielddata;
 
-import org.apache.logging.log4j.LogManager;
 import org.apache.lucene.index.SortedNumericDocValues;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
@@ -27,25 +26,19 @@ import org.apache.lucene.util.BytesRefBuilder;
 import org.elasticsearch.common.geo.GeoHashUtils;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
-import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.script.JodaCompatibleZonedDateTime;
 
 import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.time.Instant;
 import java.time.ZoneOffset;
 import java.util.AbstractList;
 import java.util.Arrays;
 import java.util.Comparator;
-import java.util.List;
-import java.util.function.BiConsumer;
 import java.util.function.UnaryOperator;
 
 /**
  * Script level doc values, the assumption is that any implementation will
- * implement a <code>getValue</code> and a <code>getValues</code> that return
- * the relevant type that then can be used in scripts.
+ * implement a {@link Longs#getValue getValue} method.
  *
  * Implementations should not internally re-use objects for the values that they
  * return as a single {@link ScriptDocValues} instance can be reused to return
@@ -53,39 +46,11 @@ import java.util.function.UnaryOperator;
  */
 public abstract class ScriptDocValues<T> extends AbstractList<T> {
 
-    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ScriptDocValues.class));
-    /**
-     * Callback for deprecated fields. In production this should always point to
-     * {@link #deprecationLogger} but tests will override it so they can test
-     * that we use the required permissions when calling it.
-     */
-    private final BiConsumer<String, String> deprecationCallback;
-
-    public ScriptDocValues() {
-        deprecationCallback = deprecationLogger::deprecatedAndMaybeLog;
-    }
-
-    /**
-     * Constructor for testing deprecation callback.
-     */
-    ScriptDocValues(BiConsumer<String, String> deprecationCallback) {
-        this.deprecationCallback = deprecationCallback;
-    }
-
     /**
      * Set the current doc ID.
      */
     public abstract void setNextDocId(int docId) throws IOException;
 
-    /**
-     * Return a copy of the list of the values for the current document.
-     */
-    public final List<T> getValues() {
-        deprecated("ScriptDocValues#getValues", "Deprecated getValues used, the field is a list and should be accessed directly."
-                + " For example, use doc['foo'] instead of doc['foo'].values.");
-        return this;
-    }
-
     // Throw meaningful exceptions if someone tries to modify the ScriptDocValues.
     @Override
     public final void add(int index, T element) {
@@ -112,21 +77,6 @@ public abstract class ScriptDocValues<T> extends AbstractList<T> {
         throw new UnsupportedOperationException("doc values are unmodifiable");
     }
 
-    /**
-     * Log a deprecation log, with the server's permissions and not the permissions
-     * of the script calling this method. We need to do this to prevent errors
-     * when rolling the log file.
-     */
-    private void deprecated(String key, String message) {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            @Override
-            public Void run() {
-                deprecationCallback.accept(key, message);
-                return null;
-            }
-        });
-    }
-
     public static final class Longs extends ScriptDocValues<Long> {
         private final SortedNumericDocValues in;
         private long[] values = new long[0];
@@ -139,14 +89,6 @@ public abstract class ScriptDocValues<T> extends AbstractList<T> {
             this.in = in;
         }
 
-        /**
-         * Constructor for testing deprecation callback.
-         */
-        Longs(SortedNumericDocValues in, BiConsumer<String, String> deprecationCallback) {
-            super(deprecationCallback);
-            this.in = in;
-        }
-
         @Override
         public void setNextDocId(int docId) throws IOException {
             if (in.advanceExact(docId)) {
@@ -204,14 +146,6 @@ public abstract class ScriptDocValues<T> extends AbstractList<T> {
             this.in = in;
         }
 
-        /**
-         * Constructor for testing deprecation callback.
-         */
-        Dates(SortedNumericDocValues in, BiConsumer<String, String> deprecationCallback) {
-            super(deprecationCallback);
-            this.in = in;
-        }
-
         /**
          * Fetch the first field value or 0 millis after epoch if there are no
          * in.
@@ -330,14 +264,6 @@ public abstract class ScriptDocValues<T> extends AbstractList<T> {
             this.in = in;
         }
 
-        /**
-         * Constructor for testing deprecation callback.
-         */
-        GeoPoints(MultiGeoPointValues in, BiConsumer<String, String> deprecationCallback) {
-            super(deprecationCallback);
-            this.in =  in;
-        }
-
         @Override
         public void setNextDocId(int docId) throws IOException {
             if (in.advanceExact(docId)) {
@@ -379,19 +305,17 @@ public abstract class ScriptDocValues<T> extends AbstractList<T> {
         }
 
         public double[] getLats() {
-            List<GeoPoint> points = getValues();
-            double[] lats = new double[points.size()];
-            for (int i = 0; i < points.size(); i++) {
-                lats[i] = points.get(i).lat();
+            double[] lats = new double[size()];
+            for (int i = 0; i < size(); i++) {
+                lats[i] = get(i).lat();
             }
             return lats;
         }
 
         public double[] getLons() {
-            List<GeoPoint> points = getValues();
-            double[] lons = new double[points.size()];
-            for (int i = 0; i < points.size(); i++) {
-                lons[i] = points.get(i).lon();
+            double[] lons = new double[size()];
+            for (int i = 0; i < size(); i++) {
+                lons[i] = get(i).lon();
             }
             return lons;
         }

+ 0 - 93
server/src/test/java/org/elasticsearch/index/fielddata/ScriptDocValuesDatesTests.java

@@ -1,93 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.index.fielddata;
-
-import org.elasticsearch.index.fielddata.ScriptDocValues.Dates;
-import org.elasticsearch.test.ESTestCase;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.BiConsumer;
-
-import static org.hamcrest.Matchers.contains;
-
-public class ScriptDocValuesDatesTests extends ESTestCase {
-
-    public void testGetValues() {
-        Set<String> keys = new HashSet<>();
-        Set<String> warnings = new HashSet<>();
-
-        Dates dates = biconsumerWrap((deprecationKey, deprecationMessage) -> {
-            keys.add(deprecationKey);
-            warnings.add(deprecationMessage);
-
-            // Create a temporary directory to prove we are running with the server's permissions.
-            createTempDir();
-        });
-
-        /*
-         * Invoke getValues() without any permissions to verify it still works.
-         * This is done using the callback created above, which creates a temp
-         * directory, which is not possible with "noPermission".
-         */
-        PermissionCollection noPermissions = new Permissions();
-        AccessControlContext noPermissionsAcc = new AccessControlContext(
-            new ProtectionDomain[] {
-                new ProtectionDomain(null, noPermissions)
-            }
-        );
-        AccessController.doPrivileged(new PrivilegedAction<Void>(){
-            public Void run() {
-                dates.getValues();
-                return null;
-            }
-        }, noPermissionsAcc);
-
-        assertThat(warnings, contains(
-            "Deprecated getValues used, the field is a list and should be accessed directly."
-           + " For example, use doc['foo'] instead of doc['foo'].values."));
-        assertThat(keys, contains("ScriptDocValues#getValues"));
-
-
-    }
-
-    private Dates biconsumerWrap(BiConsumer<String, String> deprecationHandler) {
-        return new Dates(new AbstractSortedNumericDocValues() {
-            @Override
-            public boolean advanceExact(int doc) {
-                return true;
-            }
-            @Override
-            public int docValueCount() {
-                return 0;
-            }
-            @Override
-            public long nextValue() {
-                return 0L;
-            }
-        }, deprecationHandler);
-    }
-}

+ 1 - 51
server/src/test/java/org/elasticsearch/index/fielddata/ScriptDocValuesGeoPointsTests.java

@@ -21,22 +21,10 @@ package org.elasticsearch.index.fielddata;
 
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
-import org.elasticsearch.index.fielddata.ScriptDocValues.GeoPoints;
 import org.elasticsearch.test.ESTestCase;
 
 import java.io.IOException;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
 import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.BiConsumer;
-
-import static org.hamcrest.Matchers.contains;
 
 public class ScriptDocValuesGeoPointsTests extends ESTestCase {
 
@@ -83,51 +71,18 @@ public class ScriptDocValuesGeoPointsTests extends ESTestCase {
         final double lon1 = randomLon();
         final double lon2 = randomLon();
 
-        Set<String> warnings = new HashSet<>();
-        Set<String> keys = new HashSet<>();
-
         final MultiGeoPointValues values = wrap(new GeoPoint(lat1, lon1), new GeoPoint(lat2, lon2));
-        final ScriptDocValues.GeoPoints script = geoPointsWrap(values, (deprecationKey, deprecationMessage)  -> {
-            keys.add(deprecationKey);
-            warnings.add(deprecationMessage);
+        final ScriptDocValues.GeoPoints script = new ScriptDocValues.GeoPoints(values);
 
-            // Create a temporary directory to prove we are running with the server's permissions.
-            createTempDir();
-        });
         script.setNextDocId(1);
         assertEquals(true, script.isEmpty());
         script.setNextDocId(0);
         assertEquals(false, script.isEmpty());
         assertEquals(new GeoPoint(lat1, lon1), script.getValue());
-        assertEquals(Arrays.asList(new GeoPoint(lat1, lon1), new GeoPoint(lat2, lon2)), script.getValues());
         assertEquals(lat1, script.getLat(), 0);
         assertEquals(lon1, script.getLon(), 0);
         assertTrue(Arrays.equals(new double[] {lat1, lat2}, script.getLats()));
         assertTrue(Arrays.equals(new double[] {lon1, lon2}, script.getLons()));
-
-        /*
-         * Invoke getValues() without any permissions to verify it still works.
-         * This is done using the callback created above, which creates a temp
-         * directory, which is not possible with "noPermission".
-         */
-        PermissionCollection noPermissions = new Permissions();
-        AccessControlContext noPermissionsAcc = new AccessControlContext(
-            new ProtectionDomain[] {
-                new ProtectionDomain(null, noPermissions)
-            }
-        );
-        AccessController.doPrivileged(new PrivilegedAction<Void>(){
-            public Void run() {
-                script.getValues();
-                return null;
-            }
-        }, noPermissionsAcc);
-
-        assertThat(warnings, contains(
-            "Deprecated getValues used, the field is a list and should be accessed directly."
-           + " For example, use doc['foo'] instead of doc['foo'].values."));
-        assertThat(keys, contains("ScriptDocValues#getValues"));
-
     }
 
     public void testGeoDistance() throws IOException {
@@ -155,9 +110,4 @@ public class ScriptDocValuesGeoPointsTests extends ESTestCase {
                 script.planeDistanceWithDefault(otherLat, otherLon, 42) / 1000d, 0.01);
         assertEquals(42, emptyScript.planeDistanceWithDefault(otherLat, otherLon, 42), 0);
     }
-
-    private GeoPoints geoPointsWrap(MultiGeoPointValues in, BiConsumer<String, String> deprecationHandler) {
-        return new GeoPoints(in, deprecationHandler);
-    }
-
 }

+ 4 - 49
server/src/test/java/org/elasticsearch/index/fielddata/ScriptDocValuesLongsTests.java

@@ -23,17 +23,7 @@ import org.elasticsearch.index.fielddata.ScriptDocValues.Longs;
 import org.elasticsearch.test.ESTestCase;
 
 import java.io.IOException;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.BiConsumer;
 
-import static org.hamcrest.Matchers.contains;
 
 public class ScriptDocValuesLongsTests extends ESTestCase {
     public void testLongs() throws IOException {
@@ -45,16 +35,7 @@ public class ScriptDocValuesLongsTests extends ESTestCase {
             }
         }
 
-        Set<String> warnings = new HashSet<>();
-        Set<String> keys = new HashSet<>();
-
-        Longs longs = wrap(values, (deprecationKey, deprecationMessage) -> {
-            keys.add(deprecationKey);
-            warnings.add(deprecationMessage);
-            
-            // Create a temporary directory to prove we are running with the server's permissions.
-            createTempDir();
-        });
+        Longs longs = wrap(values);
 
         for (int round = 0; round < 10; round++) {
             int d = between(0, values.length - 1);
@@ -67,42 +48,16 @@ public class ScriptDocValuesLongsTests extends ESTestCase {
                     "Use doc[<field>].size()==0 to check if a document is missing a field!", e.getMessage());
             }
             assertEquals(values[d].length, longs.size());
-            assertEquals(values[d].length, longs.getValues().size());
             for (int i = 0; i < values[d].length; i++) {
                 assertEquals(values[d][i], longs.get(i).longValue());
-                assertEquals(values[d][i], longs.getValues().get(i).longValue());
             }
 
-            Exception e = expectThrows(UnsupportedOperationException.class, () -> longs.getValues().add(100L));
+            Exception e = expectThrows(UnsupportedOperationException.class, () -> longs.add(100L));
             assertEquals("doc values are unmodifiable", e.getMessage());
         }
-
-        /*
-         * Invoke getValues() without any permissions to verify it still works.
-         * This is done using the callback created above, which creates a temp
-         * directory, which is not possible with "noPermission".
-         */
-        PermissionCollection noPermissions = new Permissions();
-        AccessControlContext noPermissionsAcc = new AccessControlContext(
-            new ProtectionDomain[] {
-                new ProtectionDomain(null, noPermissions)
-            }
-        );
-        AccessController.doPrivileged(new PrivilegedAction<Void>(){
-            public Void run() {
-                longs.getValues();
-                return null;
-            }
-        }, noPermissionsAcc);
-
-        assertThat(warnings, contains(
-            "Deprecated getValues used, the field is a list and should be accessed directly."
-            + " For example, use doc['foo'] instead of doc['foo'].values."));
-        assertThat(keys, contains("ScriptDocValues#getValues"));
-
     }
 
-    private Longs wrap(long[][] values, BiConsumer<String, String> deprecationCallback) {
+    private Longs wrap(long[][] values) {
         return new Longs(new AbstractSortedNumericDocValues() {
             long[] current;
             int i;
@@ -121,6 +76,6 @@ public class ScriptDocValuesLongsTests extends ESTestCase {
             public long nextValue() {
                 return current[i++];
             }
-        }, deprecationCallback);
+        });
     }
 }

+ 3 - 3
server/src/test/java/org/elasticsearch/search/aggregations/bucket/MinDocCountIT.java

@@ -84,19 +84,19 @@ public class MinDocCountIT extends AbstractTermsTestCase {
             scripts.put("doc['d']", vars -> {
                 Map<?, ?> doc = (Map) vars.get("doc");
                 ScriptDocValues.Doubles value = (ScriptDocValues.Doubles) doc.get("d");
-                return value.getValues();
+                return value;
             });
 
             scripts.put("doc['l']", vars -> {
                 Map<?, ?> doc = (Map) vars.get("doc");
                 ScriptDocValues.Longs value = (ScriptDocValues.Longs) doc.get("l");
-                return value.getValues();
+                return value;
             });
 
             scripts.put("doc['s']", vars -> {
                 Map<?, ?> doc = (Map) vars.get("doc");
                 ScriptDocValues.Strings value = (ScriptDocValues.Strings) doc.get("s");
-                return value.getValues();
+                return value;
             });
 
             return scripts;

+ 1 - 1
server/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java

@@ -87,7 +87,7 @@ public class RangeIT extends ESIntegTestCase {
             scripts.put("doc['" + MULTI_VALUED_FIELD_NAME + "']", vars -> {
                 Map<?, ?> doc = (Map) vars.get("doc");
                 ScriptDocValues.Longs value = (ScriptDocValues.Longs) doc.get(MULTI_VALUED_FIELD_NAME);
-                return value.getValues();
+                return value;
             });
 
             return scripts;

+ 2 - 2
server/src/test/java/org/elasticsearch/search/aggregations/metrics/CardinalityIT.java

@@ -75,7 +75,7 @@ public class CardinalityIT extends ESIntegTestCase {
             scripts.put("doc['str_values']", vars -> {
                 Map<?, ?> doc = (Map<?, ?>) vars.get("doc");
                 ScriptDocValues.Strings strValue = (ScriptDocValues.Strings) doc.get("str_values");
-                return strValue.getValues();
+                return strValue;
             });
 
             scripts.put("doc[' + singleNumericField() + '].value", vars -> {
@@ -85,7 +85,7 @@ public class CardinalityIT extends ESIntegTestCase {
 
             scripts.put("doc[' + multiNumericField(false) + ']", vars -> {
                 Map<?, ?> doc =(Map<?, ?>) vars.get("doc");
-                return ((ScriptDocValues<?>) doc.get(multiNumericField(false))).getValues();
+                return (ScriptDocValues<?>) doc.get(multiNumericField(false));
             });
 
             return scripts;

+ 1 - 1
server/src/test/java/org/elasticsearch/search/fields/SearchFieldsIT.java

@@ -156,7 +156,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
         static Object docScript(Map<String, Object> vars, String fieldName) {
             Map<?, ?> doc = (Map) vars.get("doc");
             ScriptDocValues<?> values = (ScriptDocValues<?>) doc.get(fieldName);
-            return values.getValues();
+            return values;
         }
     }
 

+ 1 - 1
server/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java

@@ -108,7 +108,7 @@ public class ExplainableScriptIT extends ESIntegTestCase {
 
         @Override
         public double execute() {
-            return ((Number) ((ScriptDocValues) getDoc().get("number_field")).getValues().get(0)).doubleValue();
+            return ((Number) ((ScriptDocValues) getDoc().get("number_field")).get(0)).doubleValue();
         }
     }
 

+ 1 - 1
server/src/test/java/org/elasticsearch/search/functionscore/RandomScoreFunctionIT.java

@@ -85,7 +85,7 @@ public class RandomScoreFunctionIT extends ESIntegTestCase {
 
         static Double scoringScript(Map<String, Object> vars, Function<ScoreAccessor, Number> scoring) {
             Map<?, ?> doc = (Map) vars.get("doc");
-            Double index = ((Number) ((ScriptDocValues<?>) doc.get("index")).getValues().get(0)).doubleValue();
+            Double index = ((Number) ((ScriptDocValues<?>) doc.get("index")).get(0)).doubleValue();
             Double score = scoring.apply((ScoreAccessor) vars.get("_score")).doubleValue();
             Integer factor = (Integer) vars.get("factor");
             return Math.log(index + (factor * score));

+ 2 - 2
server/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java

@@ -95,13 +95,13 @@ public class FieldSortIT extends ESIntegTestCase {
 
         static Double sortDoubleScript(Map<String, Object> vars) {
             Map<?, ?> doc = (Map) vars.get("doc");
-            Double index = ((Number) ((ScriptDocValues<?>) doc.get("number")).getValues().get(0)).doubleValue();
+            Double index = ((Number) ((ScriptDocValues<?>) doc.get("number")).get(0)).doubleValue();
             return index;
         }
 
         static String sortStringScript(Map<String, Object> vars) {
             Map<?, ?> doc = (Map) vars.get("doc");
-            String value = ((String) ((ScriptDocValues<?>) doc.get("keyword")).getValues().get(0));
+            String value = ((String) ((ScriptDocValues<?>) doc.get("keyword")).get(0));
             return value;
         }
     }

+ 2 - 2
server/src/test/java/org/elasticsearch/search/sort/SimpleSortIT.java

@@ -87,7 +87,7 @@ public class SimpleSortIT extends ESIntegTestCase {
 
             scripts.put("doc['id'][0]", vars -> {
                 Map<?, ?> doc = (Map) vars.get("doc");
-                return ((ScriptDocValues.Strings) doc.get("id")).getValues().get(0);
+                return ((ScriptDocValues.Strings) doc.get("id")).get(0);
             });
 
             scripts.put("get min long", vars -> getMinValueScript(vars, Long.MAX_VALUE, "lvalue", l -> (Long) l));
@@ -108,7 +108,7 @@ public class SimpleSortIT extends ESIntegTestCase {
             T retval = initialValue;
             Map<?, ?> doc = (Map) vars.get("doc");
             ScriptDocValues<?> values = (ScriptDocValues<?>) doc.get(fieldName);
-            for (Object v : values.getValues()) {
+            for (Object v : values) {
                 T value = converter.apply(v);
                 retval = (value.compareTo(retval) < 0) ? value : retval;
             }