From e7e1667a26de5472e3419c586682b92c37c6e7d3 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 18 Dec 2013 16:39:15 +0100 Subject: [PATCH] Make parsing strict for `geo_shape` query & filter and stricter for `common` query. Closes #4508 --- rest-spec | 2 +- .../org/elasticsearch/index/query/CommonTermsQueryParser.java | 2 ++ .../org/elasticsearch/index/query/GeoShapeFilterParser.java | 4 ++++ .../org/elasticsearch/index/query/GeoShapeQueryParser.java | 4 ++++ 4 files changed, 11 insertions(+), 1 deletion(-) mode change 160000 => 120000 rest-spec diff --git a/rest-spec b/rest-spec deleted file mode 160000 index 2f5f78f24d8..00000000000 --- a/rest-spec +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2f5f78f24d8fbacf69c83ab7545654c83965e846 diff --git a/rest-spec b/rest-spec new file mode 120000 index 00000000000..8093cc3fe3f --- /dev/null +++ b/rest-spec @@ -0,0 +1 @@ +../elasticsearch-rest-api-spec/ \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java b/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java index 23a1a8ddfb7..c900338ab3d 100644 --- a/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java @@ -104,6 +104,8 @@ public class CommonTermsQueryParser implements QueryParser { } } } + } else { + throw new QueryParsingException(parseContext.index(), "[common] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { if ("query".equals(currentFieldName)) { diff --git a/src/main/java/org/elasticsearch/index/query/GeoShapeFilterParser.java b/src/main/java/org/elasticsearch/index/query/GeoShapeFilterParser.java index cc76c003162..5a921329b6e 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoShapeFilterParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoShapeFilterParser.java @@ -135,6 +135,8 @@ public class GeoShapeFilterParser implements FilterParser { throw new QueryParsingException(parseContext.index(), "Type for indexed shape not provided"); } shape = fetchService.fetch(id, type, index, shapeFieldName); + } else { + throw new QueryParsingException(parseContext.index(), "[geo_shape] filter does not support [" + currentFieldName + "]"); } } } @@ -145,6 +147,8 @@ public class GeoShapeFilterParser implements FilterParser { cache = parser.booleanValue(); } else if ("_cache_key".equals(currentFieldName)) { cacheKey = new CacheKeyFilter.Key(parser.text()); + } else { + throw new QueryParsingException(parseContext.index(), "[geo_shape] filter does not support [" + currentFieldName + "]"); } } } diff --git a/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java index 46e1ceeda3e..1e3cdfbd618 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java @@ -113,6 +113,8 @@ public class GeoShapeQueryParser implements QueryParser { throw new QueryParsingException(parseContext.index(), "Type for indexed shape not provided"); } shape = fetchService.fetch(id, type, index, shapeFieldName); + } else { + throw new QueryParsingException(parseContext.index(), "[geo_shape] query does not support [" + currentFieldName + "]"); } } } @@ -121,6 +123,8 @@ public class GeoShapeQueryParser implements QueryParser { boost = parser.floatValue(); } else if ("_name".equals(currentFieldName)) { queryName = parser.text(); + } else { + throw new QueryParsingException(parseContext.index(), "[geo_shape] query does not support [" + currentFieldName + "]"); } } }