diff --git a/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java b/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java index 195e146ab7ca1..528be0369166e 100644 --- a/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java +++ b/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java @@ -183,12 +183,6 @@ public static void readMultiLineFormat(BytesReference data, if (nextMarker == -1) { break; } - // support first line with \n - if (nextMarker == 0) { - from = nextMarker + 1; - continue; - } - SearchRequest searchRequest = new SearchRequest(); if (indices != null) { searchRequest.indices(indices); diff --git a/server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java b/server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java index da22ce4c96c1a..afe957e2bf3ee 100644 --- a/server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java +++ b/server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java @@ -48,6 +48,7 @@ import static org.elasticsearch.search.RandomSearchRequestGenerator.randomSearchRequest; import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; @@ -180,6 +181,15 @@ public void testSimpleAdd4() throws Exception { assertThat(request.requests().get(2).routing(), equalTo("123")); } + public void testNoMetadata() throws Exception { + MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/msearch-no-metadata.json"); + assertThat(request.requests().size(), equalTo(4)); + for (SearchRequest searchRequest : request.requests()) { + assertThat(searchRequest.indices().length, equalTo(0)); + assertThat(searchRequest.source().query(), instanceOf(MatchAllQueryBuilder.class)); + } + } + public void testResponseErrorToXContent() { long tookInMillis = randomIntBetween(1, 1000); MultiSearchResponse response = new MultiSearchResponse( diff --git a/server/src/test/resources/org/elasticsearch/action/search/msearch-no-metadata.json b/server/src/test/resources/org/elasticsearch/action/search/msearch-no-metadata.json new file mode 100644 index 0000000000000..a13fa283eeccf --- /dev/null +++ b/server/src/test/resources/org/elasticsearch/action/search/msearch-no-metadata.json @@ -0,0 +1,8 @@ + +{ "query": {"match_all": {}}} + +{ "query": {"match_all": {}}} + +{ "query": {"match_all": {}}} + +{ "query": {"match_all": {}}}