Skip to content

Commit

Permalink
Remove type-related methods from QueryBuilders (#42284)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Christoph Büscher authored May 22, 2019
1 parent dcf2929 commit 5fb55f6
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
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;
Expand Down Expand Up @@ -433,12 +432,6 @@ public void testTerms() {
// end::terms
}

public void testType() {
// tag::type
typeQuery("my_type"); // <1>
// end::type
}

public void testWildcard() {
// tag::wildcard
wildcardQuery(
Expand Down
6 changes: 0 additions & 6 deletions docs/java-api/query-dsl/term-level-queries.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -78,6 +74,4 @@ include::regexp-query.asciidoc[]

include::fuzzy-query.asciidoc[]

include::type-query.asciidoc[]

include::ids-query.asciidoc[]
15 changes: 0 additions & 15 deletions docs/java-api/query-dsl/type-query.asciidoc

This file was deleted.

1 change: 0 additions & 1 deletion docs/java-rest/high-level/query-builders.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
|======

Expand Down
8 changes: 1 addition & 7 deletions docs/reference/query-dsl/term-level-queries.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand All @@ -87,6 +83,4 @@ include::regexp-query.asciidoc[]

include::fuzzy-query.asciidoc[]

include::type-query.asciidoc[]

include::ids-query.asciidoc[]
19 changes: 0 additions & 19 deletions docs/reference/query-dsl/type-query.asciidoc

This file was deleted.

9 changes: 1 addition & 8 deletions docs/reference/redirects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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>>.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void testSimpleChildQuery() throws Exception {
// 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void testThatGeoShapeQueryGetRequestContainsContextAndHeaders() throws Ex
.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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,6 @@ public static IdsQueryBuilder idsQuery() {
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.
*
Expand Down Expand Up @@ -426,7 +414,7 @@ public static FunctionScoreQueryBuilder functionScoreQuery(FunctionScoreQueryBui
*
* @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);
}

Expand All @@ -436,7 +424,7 @@ public static FunctionScoreQueryBuilder functionScoreQuery(ScoreFunctionBuilder
* @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));
}

Expand Down Expand Up @@ -586,15 +574,6 @@ public static WrapperQueryBuilder wrapperQuery(byte[] source) {
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.
*/
Expand Down Expand Up @@ -653,14 +632,6 @@ public static GeoShapeQueryBuilder geoShapeQuery(String name, String indexedShap
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
*
Expand All @@ -679,16 +650,6 @@ public static GeoShapeQueryBuilder geoIntersectionQuery(String name, String inde
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
*
Expand All @@ -707,16 +668,6 @@ public static GeoShapeQueryBuilder geoWithinQuery(String name, String indexedSha
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
*
Expand All @@ -735,16 +686,6 @@ public static GeoShapeQueryBuilder geoDisjointQuery(String name, String indexedS
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1801,7 +1802,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException {
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)
Expand All @@ -1824,7 +1825,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException {
// 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)
Expand All @@ -1847,7 +1848,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void testIndexShapeRouting() throws Exception {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -233,7 +234,7 @@ public void testIndexedShapeReferenceWithTypes() throws Exception {
.endObject()).setRefreshPolicy(IMMEDIATE).get();

SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(geoIntersectionQuery("location", "Big_Rectangle", "shape_type"))
.setQuery(geoIntersectionQuery("location", "Big_Rectangle"))
.get();

assertSearchResponse(searchResponse);
Expand All @@ -242,7 +243,7 @@ public void testIndexedShapeReferenceWithTypes() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void testIndexShapeRouting() throws Exception {
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));
Expand Down
Loading

0 comments on commit 5fb55f6

Please sign in to comment.