Registering a percolate query with additional "object" level metadata can fail, closes #1505.

This commit is contained in:
Shay Banon 2011-11-27 18:06:18 +02:00
parent 32f1edf6f7
commit 4be7866bd9
1 changed files with 9 additions and 1 deletions

View File

@ -232,14 +232,22 @@ public class PercolatorExecutor extends AbstractIndexComponent {
}
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;