From 2c65be2aada6979101ad6bafcc3d338263bdb3c4 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 25 Oct 2010 16:33:55 +0200 Subject: [PATCH] better exception when a field is missing --- .../elasticsearch/index/query/xcontent/RangeFilterParser.java | 4 ++++ .../elasticsearch/index/query/xcontent/TermFilterParser.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/RangeFilterParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/RangeFilterParser.java index e115928ee35..1757979e063 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/RangeFilterParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/RangeFilterParser.java @@ -103,6 +103,10 @@ public class RangeFilterParser extends AbstractIndexComponent implements XConten } } + if (fieldName == null) { + throw new QueryParsingException(index, "No field specified for range filter"); + } + Filter filter = null; MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); if (smartNameFieldMappers != null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/TermFilterParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/TermFilterParser.java index 3a225615517..87c2edeba5f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/TermFilterParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/TermFilterParser.java @@ -75,6 +75,10 @@ public class TermFilterParser extends AbstractIndexComponent implements XContent } } + if (fieldName == null) { + throw new QueryParsingException(index, "No field specified for term filter"); + } + if (value == null) { throw new QueryParsingException(index, "No value specified for term filter"); }