Skip to content

Commit

Permalink
Registering a percolate query with additional "object" level metadata…
Browse files Browse the repository at this point in the history
… can fail, closes elastic#1505.
  • Loading branch information
kimchy committed Nov 27, 2011
1 parent 8ec5efa commit cac6a3f
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -232,14 +232,22 @@ public Query parseQuery(String name, byte[] source, int sourceOffset, int source
}
Query query = null;
String currentFieldName = null;
XContentParser.Token token;
XContentParser.Token token = parser.nextToken(); // move the START_OBJECT
if (token != XContentParser.Token.START_OBJECT) {
throw new ElasticSearchException("Failed to add query [" + name + "], not starting with OBJECT");
}
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) {
if ("query".equals(currentFieldName)) {
query = queryParserService.parse(parser).query();
break;
} else {
parser.skipChildren();
}
} else if (token == XContentParser.Token.START_ARRAY) {
parser.skipChildren();
}
}
return query;
Expand Down

0 comments on commit cac6a3f

Please sign in to comment.