Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/reference/migration/migrate_8_0/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,16 @@ If you query date fields without a specified `format`, check if the values in yo
actually meant to be milliseconds-since-epoch and use a numeric value in this case. If not, use
a string value which gets parsed by either the date format set on the field in the mappings or
by `strict_date_optional_time` by default.
====

.The `geo_bounding_box` query's `type` parameter has been removed.
[%collapsible]
====
*Details* +
The `geo_bounding_box` query's `type` parameter was deprecated in 7.14.0 and has
been removed in 8.0.0. This parameter is a no-op and has no effect on the query.

*Impact* +
Discontinue use of the `type` parameter. `geo_bounding_box` queries that include
this parameter will return an error.
====
44 changes: 0 additions & 44 deletions docs/reference/query-dsl/geo-bounding-box-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ GET my_locations,my_geoshapes/_search
accept geo points with invalid latitude or longitude, set to
`COERCE` to also try to infer correct latitude or longitude. (default is `STRICT`).

|`type` |Set to one of `indexed` or `memory` to defines whether this filter will
be executed in memory or indexed. See <<geo-bbox-type,Type>> below for further details
Default is `memory`.
|=======================================================================

[[query-dsl-geo-bounding-box-query-accepted-formats]]
Expand Down Expand Up @@ -388,47 +385,6 @@ The filter can work with multiple locations / points per document. Once
a single location / point matches the filter, the document will be
included in the filter

[discrete]
[[geo-bbox-type]]
==== Type

The type of the bounding box execution by default is set to `memory`,
which means in memory checks if the doc falls within the bounding box
range. In some cases, an `indexed` option will perform faster (but note
that the `geo_point` type must have lat and lon indexed in this case).
Note, when using the indexed option, multi locations per document field
are not supported. Here is an example:

[source,console]
--------------------------------------------------
GET my_locations/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_bounding_box": {
"pin.location": {
"top_left": {
"lat": 40.73,
"lon": -74.1
},
"bottom_right": {
"lat": 40.10,
"lon": -71.12
}
},
"type": "indexed"
}
}
}
}
}
--------------------------------------------------
// TEST[warning:Deprecated field [type] used, this field is unused and will be removed entirely]

[discrete]
==== Ignore Unmapped

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void testSimpleBoundingBoxTest() throws Exception {
}

searchResponse = client().prepareSearch() // from NY
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99).type("indexed"))
.setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99))
.get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));
assertThat(searchResponse.getHits().getHits().length, equalTo(2));
Expand Down Expand Up @@ -150,8 +150,7 @@ public void testLimit2BoundingBox() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
boolQuery().must(termQuery("userid", 880)).filter(
geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875)
.type("indexed"))
geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));

Expand All @@ -164,8 +163,7 @@ public void testLimit2BoundingBox() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
boolQuery().must(termQuery("userid", 534)).filter(
geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875)
.type("indexed"))
geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875))
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));

Expand Down Expand Up @@ -216,7 +214,6 @@ public void testCompleteLonRange() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180)
.type("indexed")
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
searchResponse = client().prepareSearch()
Expand All @@ -227,7 +224,6 @@ public void testCompleteLonRange() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180)
.type("indexed")
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));

Expand All @@ -239,7 +235,6 @@ public void testCompleteLonRange() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360)
.type("indexed")
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
searchResponse = client().prepareSearch()
Expand All @@ -250,7 +245,6 @@ public void testCompleteLonRange() throws Exception {
searchResponse = client().prepareSearch()
.setQuery(
geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360)
.type("indexed")
).get();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.common.Numbers;
import org.elasticsearch.common.xcontent.ParseField;
import org.elasticsearch.common.ParsingException;
Expand Down Expand Up @@ -41,15 +42,11 @@
public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBoundingBoxQueryBuilder> {
public static final String NAME = "geo_bounding_box";

/** Default type for executing this query (memory as of this writing). */
public static final GeoExecType DEFAULT_TYPE = GeoExecType.MEMORY;

/**
* The default value for ignore_unmapped.
*/
public static final boolean DEFAULT_IGNORE_UNMAPPED = false;

private static final ParseField TYPE_FIELD = new ParseField("type").withAllDeprecated();
private static final ParseField VALIDATION_METHOD_FIELD = new ParseField("validation_method");
private static final ParseField IGNORE_UNMAPPED_FIELD = new ParseField("ignore_unmapped");

Expand All @@ -59,8 +56,6 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
private GeoBoundingBox geoBoundingBox = new GeoBoundingBox(new GeoPoint(Double.NaN, Double.NaN), new GeoPoint(Double.NaN, Double.NaN));
/** How to deal with incorrect coordinates.*/
private GeoValidationMethod validationMethod = GeoValidationMethod.DEFAULT;
/** How the query should be run. */
private GeoExecType type = DEFAULT_TYPE;

private boolean ignoreUnmapped = DEFAULT_IGNORE_UNMAPPED;

Expand All @@ -82,7 +77,9 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
super(in);
fieldName = in.readString();
geoBoundingBox = new GeoBoundingBox(in);
type = GeoExecType.readFromStream(in);
if (in.getVersion().before(Version.V_8_0_0)) {
in.readVInt(); // ignore value
}
validationMethod = GeoValidationMethod.readFromStream(in);
ignoreUnmapped = in.readBoolean();
}
Expand All @@ -91,7 +88,9 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(fieldName);
geoBoundingBox.writeTo(out);
type.writeTo(out);
if (out.getVersion().before(Version.V_8_0_0)) {
out.writeVInt(0);
}
validationMethod.writeTo(out);
out.writeBoolean(ignoreUnmapped);
}
Expand Down Expand Up @@ -213,30 +212,6 @@ public GeoValidationMethod getValidationMethod() {
return this.validationMethod;
}

/**
* Sets the type of executing of the geo bounding box. Can be either `memory` or `indexed`. Defaults
* to `memory`.
*/
public GeoBoundingBoxQueryBuilder type(GeoExecType type) {
if (type == null) {
throw new IllegalArgumentException("Type is not allowed to be null.");
}
this.type = type;
return this;
}

/**
* For BWC: Parse type from type name.
* */
public GeoBoundingBoxQueryBuilder type(String type) {
this.type = GeoExecType.fromString(type);
return this;
}
/** Returns the execution type of the geo bounding box.*/
public GeoExecType type() {
return type;
}

/** Returns the name of the field to base the bounding box computation on. */
public String fieldName() {
return this.fieldName;
Expand Down Expand Up @@ -341,7 +316,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
geoBoundingBox.toXContentFragment(builder, false);
builder.endObject();
builder.field(VALIDATION_METHOD_FIELD.getPreferredName(), validationMethod);
builder.field(TYPE_FIELD.getPreferredName(), type);
builder.field(IGNORE_UNMAPPED_FIELD.getPreferredName(), ignoreUnmapped);

printBoostAndQueryName(builder);
Expand All @@ -361,7 +335,6 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr

// bottom (minLat), top (maxLat), left (minLon), right (maxLon)
GeoBoundingBox bbox = null;
String type = "memory";

while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
Expand All @@ -382,8 +355,6 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr
validationMethod = GeoValidationMethod.fromString(parser.text());
} else if (IGNORE_UNMAPPED_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
ignoreUnmapped = parser.booleanValue();
} else if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
type = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "failed to parse [{}] query. unexpected field [{}]",
NAME, currentFieldName);
Expand All @@ -399,7 +370,6 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr
builder.setCorners(bbox.topLeft(), bbox.bottomRight());
builder.queryName(queryName);
builder.boost(boost);
builder.type(GeoExecType.fromString(type));
builder.ignoreUnmapped(ignoreUnmapped);
if (validationMethod != null) {
// ignore deprecated coerce/ignoreMalformed settings if validationMethod is set
Expand All @@ -411,15 +381,14 @@ public static GeoBoundingBoxQueryBuilder fromXContent(XContentParser parser) thr
@Override
protected boolean doEquals(GeoBoundingBoxQueryBuilder other) {
return Objects.equals(geoBoundingBox, other.geoBoundingBox) &&
Objects.equals(type, other.type) &&
Objects.equals(validationMethod, other.validationMethod) &&
Objects.equals(fieldName, other.fieldName) &&
Objects.equals(ignoreUnmapped, other.ignoreUnmapped);
}

@Override
protected int doHashCode() {
return Objects.hash(geoBoundingBox, type, validationMethod, fieldName, ignoreUnmapped);
return Objects.hash(geoBoundingBox, validationMethod, fieldName, ignoreUnmapped);
}

@Override
Expand Down

This file was deleted.

Loading