Skip to content

Commit

Permalink
Support empty first line in msearch request body (elastic#41011)
Browse files Browse the repository at this point in the history
With elastic#41442 we have deprecated support for empty line before any action metadata in msearch API. With this commit we remove support for such empty line, in place of parsing it as empty action metadata, which was previously not supported although the following items could have an empty line representing their corresponding action metadata. This way we make all times equal.

Relates to elastic#39841
  • Loading branch information
javanna authored and akhil10x5 committed May 2, 2019
1 parent 18dd12b commit 8e58277
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

{ "query": {"match_all": {}}}

{ "query": {"match_all": {}}}

{ "query": {"match_all": {}}}

{ "query": {"match_all": {}}}

0 comments on commit 8e58277

Please sign in to comment.