Browse Source

Removing some deprecated methods (#36829)

Changes:
* Removed deprecated method in InnerHitBuilder
* Removed fields() from SearchRequestBuilder
* Removed deprecated GeoDistanceSortBuilder#geohashes
Christoph Büscher 6 years ago
parent
commit
9058698d9d

+ 0 - 11
server/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java

@@ -376,17 +376,6 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
         return this;
     }
 
-    /**
-     * Adds stored fields to load and return (note, it must be stored) as part of the search request.
-     * To disable the stored fields entirely (source and metadata fields) use {@code storedField("_none_")}.
-     * @deprecated Use {@link SearchRequestBuilder#storedFields(String...)} instead.
-     */
-    @Deprecated
-    public SearchRequestBuilder fields(String... fields) {
-        sourceBuilder().storedFields(Arrays.asList(fields));
-        return this;
-    }
-
     /**
      * Adds stored fields to load and return (note, it must be stored) as part of the search request.
      * To disable the stored fields entirely (source and metadata fields) use {@code storedField("_none_")}.

+ 2 - 23
server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java

@@ -32,12 +32,12 @@ import org.elasticsearch.common.xcontent.XContentParser;
 import org.elasticsearch.script.Script;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.elasticsearch.search.builder.SearchSourceBuilder.ScriptField;
+import org.elasticsearch.search.collapse.CollapseBuilder;
 import org.elasticsearch.search.fetch.StoredFieldsContext;
 import org.elasticsearch.search.fetch.subphase.DocValueFieldsContext.FieldAndFormat;
 import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
 import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
 import org.elasticsearch.search.sort.SortBuilder;
-import org.elasticsearch.search.collapse.CollapseBuilder;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -158,6 +158,7 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
         trackScores = in.readBoolean();
         storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new);
         if (in.getVersion().before(Version.V_6_4_0)) {
+            @SuppressWarnings("unchecked")
             List<String> fieldList = (List<String>) in.readGenericValue();
             if (fieldList == null) {
                 docValueFields = null;
@@ -307,28 +308,6 @@ public final class InnerHitBuilder implements Writeable, ToXContentObject {
         return this;
     }
 
-    /**
-     * Gets the stored fields to load and return.
-     *
-     * @deprecated Use {@link InnerHitBuilder#getStoredFieldsContext()} instead.
-     */
-    @Deprecated
-    public List<String> getFieldNames() {
-        return storedFieldsContext == null ? null : storedFieldsContext.fieldNames();
-    }
-
-    /**
-     * Sets the stored fields to load and return.
-     * If none are specified, the source of the document will be returned.
-     *
-     * @deprecated Use {@link InnerHitBuilder#setStoredFieldNames(List)} instead.
-     */
-    @Deprecated
-    public InnerHitBuilder setFieldNames(List<String> fieldNames) {
-        return setStoredFieldNames(fieldNames);
-    }
-
-
     /**
      * Gets the stored fields context.
      */

+ 0 - 13
server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java

@@ -234,19 +234,6 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
         return this.points.toArray(new GeoPoint[this.points.size()]);
     }
 
-    /**
-     * The geohash of the geo point to create the range distance facets from.
-     *
-     * Deprecated - please use points(GeoPoint... points) instead.
-     */
-    @Deprecated
-    public GeoDistanceSortBuilder geohashes(String... geohashes) {
-        for (String geohash : geohashes) {
-            this.points.add(GeoPoint.fromGeohash(geohash));
-        }
-        return this;
-    }
-
     /**
      * The geo distance type used to compute the distance.
      */

+ 6 - 24
server/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderIT.java

@@ -35,6 +35,7 @@ import org.elasticsearch.test.VersionUtils;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 
@@ -222,28 +223,16 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
                 client().prepareIndex("index", "type", "d1").setSource(d1Builder),
                 client().prepareIndex("index", "type", "d2").setSource(d2Builder));
 
-        List<String> qHashes = new ArrayList<>();
-        List<GeoPoint> qPoints = new ArrayList<>();
-        createQPoints(qHashes, qPoints);
+        List<GeoPoint> qPoints = Arrays.asList(new GeoPoint(2, 1), new GeoPoint(2, 2), new GeoPoint(2, 3), new GeoPoint(2, 4));
+        Collections.shuffle(qPoints, random());
 
         GeoDistanceSortBuilder geoDistanceSortBuilder = null;
-        for (int i = 0; i < 4; i++) {
-            int at = randomInt(3 - i);
-            if (randomBoolean()) {
+        for (GeoPoint point : qPoints) {
                 if (geoDistanceSortBuilder == null) {
-                    geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, qHashes.get(at));
+                    geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, point);
                 } else {
-                    geoDistanceSortBuilder.geohashes(qHashes.get(at));
+                    geoDistanceSortBuilder.points(point);
                 }
-            } else {
-                if (geoDistanceSortBuilder == null) {
-                    geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, qPoints.get(at));
-                } else {
-                    geoDistanceSortBuilder.points(qPoints.get(at));
-                }
-            }
-            qHashes.remove(at);
-            qPoints.remove(at);
         }
 
         SearchResponse searchResponse = client().prepareSearch()
@@ -340,13 +329,6 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
                 closeTo(GeoDistance.ARC.calculate(2, 2, 1, 1, DistanceUnit.METERS), 1.e-1));
     }
 
-    protected void createQPoints(List<String> qHashes, List<GeoPoint> qPoints) {
-        GeoPoint[] qp = {new GeoPoint(2, 1), new GeoPoint(2, 2), new GeoPoint(2, 3), new GeoPoint(2, 4)};
-        qPoints.addAll(Arrays.asList(qp));
-        String[] qh = {"s02equ04ven0", "s037ms06g7h0", "s065kk0dc540", "s06g7h0dyg00"};
-        qHashes.addAll(Arrays.asList(qh));
-    }
-
     public void testCrossIndexIgnoreUnmapped() throws Exception {
         assertAcked(prepareCreate("test1").addMapping(
                 "type", "str_field", "type=keyword",