From 78eaffb646e88d958050d57eac49aa562696a11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 11 Jun 2015 17:26:19 +0200 Subject: [PATCH] Fixing edge case in RangeQueryBuilder when using time zone When specifying a time zone, RangeQueryBuilder currently throws an exeption when the field does not use DateFieldMapper, but if there are no mappers at all for that field it doesn't complain. To be consistent we also throw expection now. --- .../java/org/elasticsearch/index/query/RangeQueryBuilder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java index 548b233dbfe..4cb87df7bb6 100644 --- a/core/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/RangeQueryBuilder.java @@ -304,6 +304,10 @@ public class RangeQueryBuilder extends MultiTermQueryBuilder } if (query == null) { + if (this.timeZone != null) { + throw new QueryParsingException(parseContext, "[range] time_zone can not be applied to non date field [" + + fieldName + "]"); + } query = new TermRangeQuery(this.fieldName, BytesRefs.toBytesRef(from), BytesRefs.toBytesRef(to), includeLower, includeUpper); }