From 87313e12ba76e9bd8b9be67d33deebbc8eaa6792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= <10398885+cbuescher@users.noreply.github.com> Date: Mon, 11 Dec 2017 11:03:13 +0100 Subject: [PATCH] Use typeName() to check field type in GeoShapeQueryBuilder (#27730) The current code contains an instanceOf check and a comment that this should eventually be changed to something else. The typeName() should return a unique name for the field type in question (geo_shape) so it can be used instead. --- .../elasticsearch/index/query/GeoShapeQueryBuilder.java | 8 +++----- .../index/query/GeoShapeQueryBuilderTests.java | 9 +++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java index 0424cf6f14b..0f9006ed7da 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java @@ -341,11 +341,9 @@ public class GeoShapeQueryBuilder extends AbstractQueryBuilder queryBuilder.toQuery(createShardContext())); + assertThat(e.getMessage(), containsString("Field [mapped_string] is not of type [geo_shape] but of type [text]")); + } + public void testSerializationFailsUnlessFetched() throws IOException { QueryBuilder builder = doCreateTestQueryBuilder(true); QueryBuilder queryBuilder = Rewriteable.rewrite(builder, createShardContext());