From 52d9664993f6f0b45b97e2d1e7a8703dbd0b9e51 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Wed, 23 Sep 2015 17:33:05 +0100 Subject: [PATCH] fix to sort parsing in SearchService --- .../main/java/org/elasticsearch/search/SearchService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index 487f91824ea..879afc42261 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -695,16 +695,20 @@ public class SearchService extends AbstractLifecycleComponent { XContentParser completeSortParser = null; try { XContentBuilder completeSortBuilder = XContentFactory.jsonBuilder(); - completeSortBuilder.startArray(); + completeSortBuilder.startObject(); + completeSortBuilder.startArray("sort"); for (BytesReference sort : source.sorts()) { XContentParser parser = XContentFactory.xContent(sort).createParser(sort); parser.nextToken(); completeSortBuilder.copyCurrentStructure(parser); } completeSortBuilder.endArray(); + completeSortBuilder.endObject(); BytesReference completeSortBytes = completeSortBuilder.bytes(); completeSortParser = XContentFactory.xContent(completeSortBytes).createParser(completeSortBytes); completeSortParser.nextToken(); + completeSortParser.nextToken(); + completeSortParser.nextToken(); this.elementParsers.get("sort").parse(completeSortParser, context); } catch (Exception e) { String sSource = "_na_";