Selaa lähdekoodia

Remove type-related methods from QueryBuilders (#42284)

Removes all deprecated type-related methods from the QueryBuilders helper class
and from tests using them. Also removing related docs tests and doc pages
refering to the `type` query. All removed methods have been deprecated since
version 7.0.
Christoph Büscher 6 vuotta sitten
vanhempi
commit
5fb55f62be

+ 0 - 7
client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java

@@ -74,7 +74,6 @@ import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery;
 import static org.elasticsearch.index.query.QueryBuilders.spanWithinQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
-import static org.elasticsearch.index.query.QueryBuilders.typeQuery;
 import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery;
 import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
 import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.exponentialDecayFunction;
@@ -433,12 +432,6 @@ public class QueryDSLDocumentationTests extends ESTestCase {
         // end::terms
     }
 
-    public void testType() {
-        // tag::type
-        typeQuery("my_type");                                        // <1>
-        // end::type
-    }
-
     public void testWildcard() {
         // tag::wildcard
         wildcardQuery(

+ 0 - 6
docs/java-api/query-dsl/term-level-queries.asciidoc

@@ -53,10 +53,6 @@ The queries in this group are:
     http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance[Levenshtein edit distance]
     of 1 or 2.
 
-<<java-query-dsl-type-query,`type` query>>::
-
-    Find documents of the specified type.
-
 <<java-query-dsl-ids-query,`ids` query>>::
 
     Find documents with the specified type and IDs.
@@ -78,6 +74,4 @@ include::regexp-query.asciidoc[]
 
 include::fuzzy-query.asciidoc[]
 
-include::type-query.asciidoc[]
-
 include::ids-query.asciidoc[]

+ 0 - 15
docs/java-api/query-dsl/type-query.asciidoc

@@ -1,15 +0,0 @@
-[[java-query-dsl-type-query]]
-==== Type Query
-
-deprecated[7.0.0]
-
-Types are being removed, prefer filtering on a field instead. For
-more information, see {ref}/removal-of-types.html[Removal of mapping types].
-
-See {ref}/query-dsl-type-query.html[Type Query]
-
-["source","java",subs="attributes,callouts,macros"]
---------------------------------------------------
-include-tagged::{query-dsl-test}[type]
---------------------------------------------------
-<1> type

+ 0 - 1
docs/java-rest/high-level/query-builders.asciidoc

@@ -40,7 +40,6 @@ This page lists all the available search queries with their corresponding `Query
 | {ref}/query-dsl-wildcard-query.html[Wildcard]                       | {query-ref}/WildcardQueryBuilder.html[WildcardQueryBuilder]                         | {query-ref}/QueryBuilders.html#wildcardQuery-java.lang.String-java.lang.String-[QueryBuilders.wildcardQuery()]
 | {ref}/query-dsl-regexp-query.html[Regexp]                           | {query-ref}/RegexpQueryBuilder.html[RegexpQueryBuilder]                             | {query-ref}/QueryBuilders.html#regexpQuery-java.lang.String-java.lang.String-[QueryBuilders.regexpQuery()]
 | {ref}/query-dsl-fuzzy-query.html[Fuzzy]                             | {query-ref}/FuzzyQueryBuilder.html[FuzzyQueryBuilder]                               | {query-ref}/QueryBuilders.html#fuzzyQuery-java.lang.String-java.lang.String-[QueryBuilders.fuzzyQuery()]
-| {ref}/query-dsl-type-query.html[Type]                               | {query-ref}/TypeQueryBuilder.html[TypeQueryBuilder]                                 | {query-ref}/QueryBuilders.html#typeQuery-java.lang.String-[QueryBuilders.typeQuery()]
 | {ref}/query-dsl-ids-query.html[Ids]                                 | {query-ref}/IdsQueryBuilder.html[IdsQueryBuilder]                                   | {query-ref}/QueryBuilders.html#idsQuery--[QueryBuilders.idsQuery()]
 |======
 

+ 1 - 7
docs/reference/query-dsl/term-level-queries.asciidoc

@@ -60,13 +60,9 @@ The queries in this group are:
     http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance[Levenshtein edit distance]
     of 1 or 2.
 
-<<query-dsl-type-query,`type` query>>::
-
-    Find documents of the specified type.
-
 <<query-dsl-ids-query,`ids` query>>::
 
-    Find documents with the specified type and IDs.
+    Find documents with the specified IDs.
 
 
 include::term-query.asciidoc[]
@@ -87,6 +83,4 @@ include::regexp-query.asciidoc[]
 
 include::fuzzy-query.asciidoc[]
 
-include::type-query.asciidoc[]
-
 include::ids-query.asciidoc[]

+ 0 - 19
docs/reference/query-dsl/type-query.asciidoc

@@ -1,19 +0,0 @@
-[[query-dsl-type-query]]
-=== Type Query
-
-deprecated[7.0.0,Types and the `type` query are deprecated and in the process of being removed. See <<removal-of-types>>.]
-
-Filters documents matching the provided document / mapping type.
-
-[source,js]
---------------------------------------------------
-GET /_search
-{
-    "query": {
-        "type" : {
-            "value" : "_doc"
-        }
-    }
-}    
---------------------------------------------------
-// CONSOLE

+ 1 - 8
docs/reference/redirects.asciidoc

@@ -248,13 +248,6 @@ The `terms` filter has been replaced by the <<query-dsl-terms-query>>. It behave
 as a query in ``query context'' and as a filter in ``filter context'' (see
 <<query-dsl>>).
 
-[role="exclude",id="query-dsl-type-filter"]
-=== Type Filter
-
-The `type` filter has been replaced by the <<query-dsl-type-query>>. It behaves
-as a query in ``query context'' and as a filter in ``filter context'' (see
-<<query-dsl>>).
-
 [role="exclude",id="query-dsl-flt-query"]
 === Fuzzy Like This Query
 
@@ -601,4 +594,4 @@ See <<faster-phrase-queries>>.
 
 [role="exclude",id="_faster_prefix_queries_with_literal_index_prefixes_literal.html"]
 
-See <<faster-prefix-queries>>.
+See <<faster-prefix-queries>>.

+ 1 - 1
modules/parent-join/src/test/java/org/elasticsearch/join/query/ChildQuerySearchIT.java

@@ -179,7 +179,7 @@ public class ChildQuerySearchIT extends ParentChildTestCase {
         // TEST FETCHING _parent from child
         SearchResponse searchResponse;
         searchResponse = client().prepareSearch("test")
-                .setQuery(idsQuery("doc").addIds("c1")).get();
+                .setQuery(idsQuery().addIds("c1")).get();
         assertNoFailures(searchResponse);
         assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
         assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("c1"));

+ 1 - 1
qa/smoke-test-http/src/test/java/org/elasticsearch/http/ContextAndHeaderTransportIT.java

@@ -177,7 +177,7 @@ public class ContextAndHeaderTransportIT extends HttpSmokeTestCase {
             .get();
         transportClient().admin().indices().prepareRefresh(lookupIndex, queryIndex).get();
 
-        GeoShapeQueryBuilder queryBuilder = QueryBuilders.geoShapeQuery("location", "1", "type")
+        GeoShapeQueryBuilder queryBuilder = QueryBuilders.geoShapeQuery("location", "1")
             .indexedShapeIndex(lookupIndex)
             .indexedShapePath("location");
 

+ 2 - 61
server/src/main/java/org/elasticsearch/index/query/QueryBuilders.java

@@ -117,18 +117,6 @@ public final class QueryBuilders {
         return new IdsQueryBuilder();
     }
 
-    /**
-     * Constructs a query that will match only specific ids within types.
-     *
-     * @param types The mapping/doc type
-     *
-     * @deprecated Types are in the process of being removed, use {@link #idsQuery()} instead.
-     */
-    @Deprecated
-    public static IdsQueryBuilder idsQuery(String... types) {
-        return new IdsQueryBuilder().types(types);
-    }
-
     /**
      * A Query that matches documents containing a term.
      *
@@ -426,7 +414,7 @@ public final class QueryBuilders {
      *
      * @param function The function builder used to custom score
      */
-    public static FunctionScoreQueryBuilder functionScoreQuery(ScoreFunctionBuilder function) {
+    public static FunctionScoreQueryBuilder functionScoreQuery(ScoreFunctionBuilder<?> function) {
         return new FunctionScoreQueryBuilder(function);
     }
 
@@ -436,7 +424,7 @@ public final class QueryBuilders {
      * @param queryBuilder The query to custom score
      * @param function     The function builder used to custom score
      */
-    public static FunctionScoreQueryBuilder functionScoreQuery(QueryBuilder queryBuilder, ScoreFunctionBuilder function) {
+    public static FunctionScoreQueryBuilder functionScoreQuery(QueryBuilder queryBuilder, ScoreFunctionBuilder<?> function) {
         return (new FunctionScoreQueryBuilder(queryBuilder, function));
     }
 
@@ -586,15 +574,6 @@ public final class QueryBuilders {
         return new WrapperQueryBuilder(source);
     }
 
-    /**
-     * A filter based on doc/mapping type.
-     * @deprecated Types are going away, prefer filtering on a field.
-     */
-    @Deprecated
-    public static TypeQueryBuilder typeQuery(String type) {
-        return new TypeQueryBuilder(type);
-    }
-
     /**
      * A terms query that can extract the terms from another doc in an index.
      */
@@ -653,14 +632,6 @@ public final class QueryBuilders {
         return new GeoShapeQueryBuilder(name, indexedShapeId);
     }
 
-    /**
-     * @deprecated Types are in the process of being removed, use {@link #geoShapeQuery(String, String)} instead.
-     */
-    @Deprecated
-    public static GeoShapeQueryBuilder geoShapeQuery(String name, String indexedShapeId, String indexedShapeType) {
-        return new GeoShapeQueryBuilder(name, indexedShapeId, indexedShapeType);
-    }
-
     /**
      * A filter to filter indexed shapes intersecting with shapes
      *
@@ -679,16 +650,6 @@ public final class QueryBuilders {
         return builder;
     }
 
-    /**
-     * @deprecated Types are in the process of being removed, use {@link #geoIntersectionQuery(String, String)} instead.
-     */
-    @Deprecated
-    public static GeoShapeQueryBuilder geoIntersectionQuery(String name, String indexedShapeId, String indexedShapeType) {
-        GeoShapeQueryBuilder builder = geoShapeQuery(name, indexedShapeId, indexedShapeType);
-        builder.relation(ShapeRelation.INTERSECTS);
-        return builder;
-    }
-
     /**
      * A filter to filter indexed shapes that are contained by a shape
      *
@@ -707,16 +668,6 @@ public final class QueryBuilders {
         return builder;
     }
 
-    /**
-     * @deprecated Types are in the process of being removed, use {@link #geoWithinQuery(String, String)} instead.
-     */
-    @Deprecated
-    public static GeoShapeQueryBuilder geoWithinQuery(String name, String indexedShapeId, String indexedShapeType) {
-        GeoShapeQueryBuilder builder = geoShapeQuery(name, indexedShapeId, indexedShapeType);
-        builder.relation(ShapeRelation.WITHIN);
-        return builder;
-    }
-
     /**
      * A filter to filter indexed shapes that are not intersection with the query shape
      *
@@ -735,16 +686,6 @@ public final class QueryBuilders {
         return builder;
     }
 
-    /**
-     * @deprecated Types are in the process of being removed, use {@link #geoDisjointQuery(String, String)} instead.
-     */
-    @Deprecated
-    public static GeoShapeQueryBuilder geoDisjointQuery(String name, String indexedShapeId, String indexedShapeType) {
-        GeoShapeQueryBuilder builder = geoShapeQuery(name, indexedShapeId, indexedShapeType);
-        builder.relation(ShapeRelation.DISJOINT);
-        return builder;
-    }
-
     /**
      * A filter to filter only documents where a field exists in them.
      *

+ 4 - 3
server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlighterSearchIT.java

@@ -19,6 +19,7 @@
 package org.elasticsearch.search.fetch.subphase.highlight;
 
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenizer;
@@ -1801,7 +1802,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
         index("test", "type1", "2", "text", new String[] {"", text2});
         refresh();
 
-        IdsQueryBuilder idsQueryBuilder = QueryBuilders.idsQuery("type1").addIds("2");
+        IdsQueryBuilder idsQueryBuilder = QueryBuilders.idsQuery().addIds("2");
         field.highlighterType("plain");
         response = client().prepareSearch("test")
                 .setQuery(idsQueryBuilder)
@@ -1824,7 +1825,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
         // But if the field was actually empty then you should get no highlighting field
         index("test", "type1", "3", "text", new String[] {});
         refresh();
-        idsQueryBuilder = QueryBuilders.idsQuery("type1").addIds("3");
+        idsQueryBuilder = QueryBuilders.idsQuery().addIds("3");
         field.highlighterType("plain");
         response = client().prepareSearch("test")
                 .setQuery(idsQueryBuilder)
@@ -1847,7 +1848,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
         index("test", "type1", "4");
         refresh();
 
-        idsQueryBuilder = QueryBuilders.idsQuery("type1").addIds("4");
+        idsQueryBuilder = QueryBuilders.idsQuery().addIds("4");
         field.highlighterType("plain");
         response = client().prepareSearch("test")
                 .setQuery(idsQueryBuilder)

+ 1 - 1
server/src/test/java/org/elasticsearch/search/geo/GeoShapeIntegrationIT.java

@@ -153,7 +153,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
         indexRandom(true, client().prepareIndex("test", "doc", "0").setSource(source, XContentType.JSON).setRouting("ABC"));
 
         SearchResponse searchResponse = client().prepareSearch("test").setQuery(
-            geoShapeQuery("shape", "0", "doc").indexedShapeIndex("test").indexedShapeRouting("ABC")
+            geoShapeQuery("shape", "0").indexedShapeIndex("test").indexedShapeRouting("ABC")
         ).get();
 
         assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));

+ 3 - 2
server/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java

@@ -20,6 +20,7 @@
 package org.elasticsearch.search.geo;
 
 import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
+
 import org.apache.lucene.geo.GeoTestUtil;
 import org.elasticsearch.action.get.GetResponse;
 import org.elasticsearch.action.index.IndexRequest;
@@ -233,7 +234,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
                 .endObject()).setRefreshPolicy(IMMEDIATE).get();
 
         SearchResponse searchResponse = client().prepareSearch("test")
-                .setQuery(geoIntersectionQuery("location", "Big_Rectangle", "shape_type"))
+                .setQuery(geoIntersectionQuery("location", "Big_Rectangle"))
                 .get();
 
         assertSearchResponse(searchResponse);
@@ -242,7 +243,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
         assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
 
         searchResponse = client().prepareSearch("test")
-                .setQuery(geoShapeQuery("location", "Big_Rectangle", "shape_type"))
+                .setQuery(geoShapeQuery("location", "Big_Rectangle"))
                 .get();
 
         assertSearchResponse(searchResponse);

+ 1 - 1
server/src/test/java/org/elasticsearch/search/geo/LegacyGeoShapeIntegrationIT.java

@@ -155,7 +155,7 @@ public class LegacyGeoShapeIntegrationIT extends ESIntegTestCase {
         indexRandom(true, client().prepareIndex("test", "doc", "0").setSource(source, XContentType.JSON).setRouting("ABC"));
 
         SearchResponse searchResponse = client().prepareSearch("test").setQuery(
-            geoShapeQuery("shape", "0", "doc").indexedShapeIndex("test").indexedShapeRouting("ABC")
+            geoShapeQuery("shape", "0").indexedShapeIndex("test").indexedShapeRouting("ABC")
         ).get();
 
         assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));

+ 6 - 11
server/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java

@@ -26,7 +26,6 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.search.SearchType;
 import org.elasticsearch.bootstrap.JavaVersion;
-import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.document.DocumentField;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.time.DateFormatter;
@@ -92,7 +91,6 @@ import static org.elasticsearch.index.query.QueryBuilders.spanTermQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termsLookupQuery;
 import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
-import static org.elasticsearch.index.query.QueryBuilders.typeQuery;
 import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery;
 import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -486,9 +484,6 @@ public class SearchQueryIT extends ESIntegTestCase {
         indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "value1"),
                 client().prepareIndex("test", "type1", "2").setSource("field1", "value1"));
 
-        assertHitCount(client().prepareSearch().setQuery(typeQuery("type1")).get(), 2L);
-        assertHitCount(client().prepareSearch().setQuery(typeQuery("type2")).get(), 0L);
-
         assertHitCount(client().prepareSearch().setTypes("type1").setQuery(matchAllQuery()).get(), 2L);
         assertHitCount(client().prepareSearch().setTypes("type2").setQuery(matchAllQuery()).get(), 0L);
 
@@ -502,7 +497,7 @@ public class SearchQueryIT extends ESIntegTestCase {
                 client().prepareIndex("test", "type1", "2").setSource("field1", "value2"),
                 client().prepareIndex("test", "type1", "3").setSource("field1", "value3"));
 
-        SearchResponse searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery("type1").addIds("1", "3"))).get();
+        SearchResponse searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery().addIds("1", "3"))).get();
         assertHitCount(searchResponse, 2L);
         assertSearchHits(searchResponse, "1", "3");
 
@@ -511,7 +506,7 @@ public class SearchQueryIT extends ESIntegTestCase {
         assertHitCount(searchResponse, 2L);
         assertSearchHits(searchResponse, "1", "3");
 
-        searchResponse = client().prepareSearch().setQuery(idsQuery("type1").addIds("1", "3")).get();
+        searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1", "3")).get();
         assertHitCount(searchResponse, 2L);
         assertSearchHits(searchResponse, "1", "3");
 
@@ -520,7 +515,7 @@ public class SearchQueryIT extends ESIntegTestCase {
         assertHitCount(searchResponse, 2L);
         assertSearchHits(searchResponse, "1", "3");
 
-        searchResponse = client().prepareSearch().setQuery(idsQuery("type1").addIds("7", "10")).get();
+        searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("7", "10")).get();
         assertHitCount(searchResponse, 0L);
 
         // repeat..., with terms
@@ -1156,7 +1151,7 @@ public class SearchQueryIT extends ESIntegTestCase {
         client().prepareIndex("test", "_doc", "3").setSource("field1", "value3").get();
         refresh();
 
-        SearchResponse searchResponse = client().prepareSearch().setQuery(idsQuery("_doc").addIds("1", "2")).get();
+        SearchResponse searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1", "2")).get();
         assertHitCount(searchResponse, 2L);
         assertThat(searchResponse.getHits().getHits().length, equalTo(2));
 
@@ -1168,11 +1163,11 @@ public class SearchQueryIT extends ESIntegTestCase {
         assertHitCount(searchResponse, 2L);
         assertThat(searchResponse.getHits().getHits().length, equalTo(2));
 
-        searchResponse = client().prepareSearch().setQuery(idsQuery(Strings.EMPTY_ARRAY).addIds("1")).get();
+        searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1")).get();
         assertHitCount(searchResponse, 1L);
         assertThat(searchResponse.getHits().getHits().length, equalTo(1));
 
-        searchResponse = client().prepareSearch().setQuery(idsQuery("type1", "type2", "_doc").addIds("1", "2", "3", "4")).get();
+        searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1", "2", "3", "4")).get();
         assertHitCount(searchResponse, 3L);
         assertThat(searchResponse.getHits().getHits().length, equalTo(3));
     }