fix SearchSourceBuilder.fromXContent to allow sort to be an object

This commit is contained in:
Colin Goodheart-Smithe 2015-09-23 23:12:36 +01:00
parent a163a0fc89
commit ce7dde08d0
1 changed files with 5 additions and 0 deletions

View File

@ -807,6 +807,11 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(parser.contentType());
xContentBuilder.copyCurrentStructure(parser);
builder.suggestBuilder = xContentBuilder.bytes();
} else if (context.parseFieldMatcher().match(currentFieldName, SORT_FIELD)) {
List<BytesReference> sorts = new ArrayList<>();
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(parser.contentType()).copyCurrentStructure(parser);
sorts.add(xContentBuilder.bytes());
builder.sorts = sorts;
} else {
throw new ParsingException(parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].",
parser.getTokenLocation());