|
19 | 19 |
|
20 | 20 | package org.elasticsearch.action.search;
|
21 | 21 |
|
| 22 | +import org.apache.logging.log4j.LogManager; |
22 | 23 | import org.elasticsearch.action.support.IndicesOptions;
|
23 | 24 | import org.elasticsearch.common.CheckedBiConsumer;
|
24 | 25 | import org.elasticsearch.common.CheckedRunnable;
|
25 | 26 | import org.elasticsearch.common.ParseField;
|
26 | 27 | import org.elasticsearch.common.Strings;
|
27 | 28 | import org.elasticsearch.common.bytes.BytesArray;
|
| 29 | +import org.elasticsearch.common.logging.DeprecationLogger; |
28 | 30 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
29 | 31 | import org.elasticsearch.common.xcontent.XContentParser;
|
30 | 32 | import org.elasticsearch.common.xcontent.XContentType;
|
|
48 | 50 | import static org.elasticsearch.search.RandomSearchRequestGenerator.randomSearchRequest;
|
49 | 51 | import static org.elasticsearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode;
|
50 | 52 | import static org.hamcrest.Matchers.equalTo;
|
| 53 | +import static org.hamcrest.Matchers.instanceOf; |
51 | 54 | import static org.hamcrest.Matchers.is;
|
52 | 55 | import static org.hamcrest.Matchers.nullValue;
|
53 | 56 |
|
54 | 57 | public class MultiSearchRequestTests extends ESTestCase {
|
| 58 | + |
| 59 | + private static final DeprecationLogger deprecationLogger = new DeprecationLogger( |
| 60 | + LogManager.getLogger(MultiSearchRequestTests.class)); |
| 61 | + |
55 | 62 | public void testSimpleAdd() throws Exception {
|
56 | 63 | MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/simple-msearch1.json");
|
57 | 64 | assertThat(request.requests().size(),
|
@@ -180,6 +187,28 @@ public void testSimpleAdd4() throws Exception {
|
180 | 187 | assertThat(request.requests().get(2).routing(), equalTo("123"));
|
181 | 188 | }
|
182 | 189 |
|
| 190 | + public void testEmptyFirstLine1() throws Exception { |
| 191 | + MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/msearch-empty-first-line1.json"); |
| 192 | + assertThat(request.requests().size(), equalTo(4)); |
| 193 | + for (SearchRequest searchRequest : request.requests()) { |
| 194 | + assertThat(searchRequest.indices().length, equalTo(0)); |
| 195 | + assertThat(searchRequest.source().query(), instanceOf(MatchAllQueryBuilder.class)); |
| 196 | + } |
| 197 | + assertWarnings("support for empty first line before any action metadata in msearch API is deprecated and will be removed " + |
| 198 | + "in the next major version"); |
| 199 | + } |
| 200 | + |
| 201 | + public void testEmptyFirstLine2() throws Exception { |
| 202 | + MultiSearchRequest request = parseMultiSearchRequest("/org/elasticsearch/action/search/msearch-empty-first-line2.json"); |
| 203 | + assertThat(request.requests().size(), equalTo(4)); |
| 204 | + for (SearchRequest searchRequest : request.requests()) { |
| 205 | + assertThat(searchRequest.indices().length, equalTo(0)); |
| 206 | + assertThat(searchRequest.source().query(), instanceOf(MatchAllQueryBuilder.class)); |
| 207 | + } |
| 208 | + assertWarnings("support for empty first line before any action metadata in msearch API is deprecated and will be removed " + |
| 209 | + "in the next major version"); |
| 210 | + } |
| 211 | + |
183 | 212 | public void testResponseErrorToXContent() {
|
184 | 213 | long tookInMillis = randomIntBetween(1, 1000);
|
185 | 214 | MultiSearchResponse response = new MultiSearchResponse(
|
@@ -262,7 +291,7 @@ public void testMultiLineSerialization() throws IOException {
|
262 | 291 | parsedRequest.add(r);
|
263 | 292 | };
|
264 | 293 | MultiSearchRequest.readMultiLineFormat(new BytesArray(originalBytes), xContentType.xContent(),
|
265 |
| - consumer, null, null, null, null, null, null, xContentRegistry(), true); |
| 294 | + consumer, null, null, null, null, null, null, xContentRegistry(), true, deprecationLogger); |
266 | 295 | assertEquals(originalRequest, parsedRequest);
|
267 | 296 | }
|
268 | 297 | }
|
|
0 commit comments