From 5306de3ce32f0682cde398090d5875cc5478dcbc Mon Sep 17 00:00:00 2001 From: Isabel Drost-Fromm Date: Thu, 28 Apr 2016 13:56:50 +0200 Subject: [PATCH] Deprecate coerce/ignore_malformed for GeoPolygonQueryBuilder Includes update to parsing code, tests, migration docs and reference docs. --- .../index/query/GeoPolygonQueryBuilder.java | 10 ++--- .../query/GeoPolygonQueryBuilderTests.java | 37 +++++++++++++++++-- .../migration/migrate_5_0/search.asciidoc | 1 + .../query-dsl/geo-polygon-query.asciidoc | 5 ++- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java index d415c87b5ab..35ab98e25de 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryBuilder.java @@ -54,8 +54,10 @@ public class GeoPolygonQueryBuilder extends AbstractQueryBuilder parseQuery(json)); + assertTrue(e.getMessage().startsWith("Deprecated field ")); + + } + + public void testFromJsonCoerceDeprecated() throws IOException { + String json = + "{\n" + + " \"geo_polygon\" : {\n" + + " \"person.location\" : {\n" + + " \"points\" : [ [ -70.0, 40.0 ], [ -80.0, 30.0 ], [ -90.0, 20.0 ], [ -70.0, 40.0 ] ]\n" + + " },\n" + + " \"coerce\" : false,\n" + + " \"ignore_unmapped\" : false,\n" + + " \"boost\" : 1.0\n" + + " }\n" + + "}"; + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parseQuery(json)); + assertTrue(e.getMessage().startsWith("Deprecated field ")); + } + @Override public void testMustRewrite() throws IOException { assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0); diff --git a/docs/reference/migration/migrate_5_0/search.asciidoc b/docs/reference/migration/migrate_5_0/search.asciidoc index 2d22ee1c1c3..a2c56996c2b 100644 --- a/docs/reference/migration/migrate_5_0/search.asciidoc +++ b/docs/reference/migration/migrate_5_0/search.asciidoc @@ -126,6 +126,7 @@ in favour of `query` and `no_match_query`. * The `exists` query will now fail if the `_field_names` field is disabled. +* Deprecated support for the coerce, normalize, ignore_malformed parameters in GeoPolygonQuery. Use parameter validation_method instead. ==== Top level `filter` parameter diff --git a/docs/reference/query-dsl/geo-polygon-query.asciidoc b/docs/reference/query-dsl/geo-polygon-query.asciidoc index 938a0b3dc87..ef80de82079 100644 --- a/docs/reference/query-dsl/geo-polygon-query.asciidoc +++ b/docs/reference/query-dsl/geo-polygon-query.asciidoc @@ -34,8 +34,9 @@ points. Here is an example: |Option |Description |`_name` |Optional name field to identify the filter -|`ignore_malformed` |Set to `true` to accept geo points with invalid latitude or -longitude (default is `false`). +|`validation_method` |Set to `IGNORE_MALFORMED` to accept geo points with +invalid latitude or longitude, `COERCE` to try and infer correct latitude +or longitude, or `STRICT` (default is `STRICT`). |======================================================================= [float]