From 63da68e48067dc0388414deed1be4f78ddcc0f69 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Wed, 23 Sep 2015 18:50:45 +0100 Subject: [PATCH] test fixes --- .../action/search/SearchRequest.java | 15 +++++++++------ .../index/query/GeoShapeQueryBuilder.java | 10 ++++++++-- .../org/elasticsearch/search/SearchService.java | 10 ++++++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java index 538fb05469d..1fabe313536 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -23,12 +23,9 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Requests; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; @@ -334,8 +331,9 @@ public class SearchRequest extends ActionRequest implements Indic if (in.readBoolean()) { scroll = readScroll(in); } - - source = SearchSourceBuilder.PROTOTYPE.readFrom(in); + if (in.readBoolean()) { + source = SearchSourceBuilder.PROTOTYPE.readFrom(in); + } types = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); @@ -363,7 +361,12 @@ public class SearchRequest extends ActionRequest implements Indic out.writeBoolean(true); scroll.writeTo(out); } - source.writeTo(out); + if (source == null) { + out.writeBoolean(false); + } else { + out.writeBoolean(true); + source.writeTo(out); + } out.writeStringArray(types); indicesOptions.writeIndicesOptions(out); out.writeOptionalBoolean(requestCache); diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java index 403ed19d5ca..7fddc486352 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java @@ -432,7 +432,9 @@ public class GeoShapeQueryBuilder extends AbstractQueryBuilder { BytesReference run = (BytesReference) executable.run(); try (XContentParser parser = XContentFactory.xContent(run).createParser(run)) { // NOCOMMIT this override the source entirely - request.source(SearchSourceBuilder.PROTOTYPE.fromXContent(parser, new QueryParseContext(indexService.queryParserService().indicesQueriesRegistry()))); + QueryParseContext queryParseContext = new QueryParseContext(indexService.queryParserService().indicesQueriesRegistry()); + queryParseContext.reset(parser); + request.source(SearchSourceBuilder.PROTOTYPE.fromXContent(parser, queryParseContext)); } } parseSource(context, request.source()); @@ -776,16 +778,20 @@ public class SearchService extends AbstractLifecycleComponent { XContentParser completeRescoreParser = null; try { XContentBuilder completeRescoreBuilder = XContentFactory.jsonBuilder(); - completeRescoreBuilder.startArray(); + completeRescoreBuilder.startObject(); + completeRescoreBuilder.startArray("rescore"); for (BytesReference rescore : source.rescores()) { XContentParser parser = XContentFactory.xContent(rescore).createParser(rescore); parser.nextToken(); completeRescoreBuilder.copyCurrentStructure(parser); } completeRescoreBuilder.endArray(); + completeRescoreBuilder.endObject(); BytesReference completeRescoreBytes = completeRescoreBuilder.bytes(); completeRescoreParser = XContentFactory.xContent(completeRescoreBytes).createParser(completeRescoreBytes); completeRescoreParser.nextToken(); + completeRescoreParser.nextToken(); + completeRescoreParser.nextToken(); this.elementParsers.get("rescore").parse(completeRescoreParser, context); } catch (Exception e) { String sSource = "_na_";