Skip to content

Commit 8508795

Browse files
authored
Support empty first line in msearch request body (#41011)
With #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 #39841
1 parent 2154a97 commit 8508795

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java

-6
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ public static void readMultiLineFormat(BytesReference data,
183183
if (nextMarker == -1) {
184184
break;
185185
}
186-
// support first line with \n
187-
if (nextMarker == 0) {
188-
from = nextMarker + 1;
189-
continue;
190-
}
191-
192186
SearchRequest searchRequest = new SearchRequest();
193187
if (indices != null) {
194188
searchRequest.indices(indices);

server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import static org.elasticsearch.search.RandomSearchRequestGenerator.randomSearchRequest;
4949
import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;
5050
import static org.hamcrest.Matchers.equalTo;
51+
import static org.hamcrest.Matchers.instanceOf;
5152
import static org.hamcrest.Matchers.is;
5253
import static org.hamcrest.Matchers.nullValue;
5354

@@ -180,6 +181,15 @@ public void testSimpleAdd4() throws Exception {
180181
assertThat(request.requests().get(2).routing(), equalTo("123"));
181182
}
182183

184+
public void testNoMetadata() throws Exception {
185+
MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/msearch-no-metadata.json");
186+
assertThat(request.requests().size(), equalTo(4));
187+
for (SearchRequest searchRequest : request.requests()) {
188+
assertThat(searchRequest.indices().length, equalTo(0));
189+
assertThat(searchRequest.source().query(), instanceOf(MatchAllQueryBuilder.class));
190+
}
191+
}
192+
183193
public void testResponseErrorToXContent() {
184194
long tookInMillis = randomIntBetween(1, 1000);
185195
MultiSearchResponse response = new MultiSearchResponse(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
{ "query": {"match_all": {}}}
3+
4+
{ "query": {"match_all": {}}}
5+
6+
{ "query": {"match_all": {}}}
7+
8+
{ "query": {"match_all": {}}}

0 commit comments

Comments
 (0)