Use XContentParser.isBooleanValue to detect all boolean values for the `_source` parameter for both _mget and _search

Closes #3981
This commit is contained in:
Boaz Leskes 2013-10-26 22:19:05 +02:00
parent 0f8149dca4
commit 68de46ff05
2 changed files with 4 additions and 2 deletions

View File

@ -322,10 +322,12 @@ public class MultiGetRequest extends ActionRequest<MultiGetRequest> {
} else if ("_version_type".equals(currentFieldName) || "_versionType".equals(currentFieldName) || "version_type".equals(currentFieldName) || "versionType".equals(currentFieldName)) {
versionType = VersionType.fromString(parser.text());
} else if ("_source".equals(currentFieldName)) {
if (token == XContentParser.Token.VALUE_BOOLEAN) {
if (parser.isBooleanValue()) {
fetchSourceContext = new FetchSourceContext(parser.booleanValue());
} else if (token == XContentParser.Token.VALUE_STRING) {
fetchSourceContext = new FetchSourceContext(new String[]{parser.text()});
} else {
throw new ElasticSearchParseException("illegal type for _source: [" + token + "]");
}
}
} else if (token == XContentParser.Token.START_ARRAY) {

View File

@ -48,7 +48,7 @@ public class FetchSourceParseElement implements SearchParseElement {
List<String> includes = null, excludes = null;
String currentFieldName = null;
token = parser.currentToken(); // we get it on the value
if (token == XContentParser.Token.VALUE_BOOLEAN) {
if (parser.isBooleanValue()) {
context.fetchSourceContext(new FetchSourceContext(parser.booleanValue()));
return;
} else if (token == XContentParser.Token.VALUE_STRING) {