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.
This commit is contained in:
Christoph Büscher 2015-06-11 17:26:19 +02:00
parent bd2e1632de
commit 78eaffb646
1 changed files with 4 additions and 0 deletions

View File

@ -304,6 +304,10 @@ public class RangeQueryBuilder extends MultiTermQueryBuilder<RangeQueryBuilder>
} }
if (query == null) { 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); query = new TermRangeQuery(this.fieldName, BytesRefs.toBytesRef(from), BytesRefs.toBytesRef(to), includeLower, includeUpper);
} }