|
17 | 17 | import org.elasticsearch.action.get.GetRequest; |
18 | 18 | import org.elasticsearch.action.index.IndexRequest; |
19 | 19 | import org.elasticsearch.action.search.SearchRequest; |
20 | | -import org.elasticsearch.action.search.SearchResponse; |
21 | | -import org.elasticsearch.client.Request; |
22 | 20 | import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; |
23 | 21 | import org.elasticsearch.cluster.metadata.Template; |
24 | 22 | import org.elasticsearch.common.compress.CompressedXContent; |
25 | 23 | import org.elasticsearch.common.settings.Settings; |
26 | 24 | import org.elasticsearch.common.time.DateFormatter; |
27 | 25 | import org.elasticsearch.common.time.FormatNames; |
28 | 26 | import org.elasticsearch.datastreams.DataStreamsPlugin; |
29 | | -import org.elasticsearch.index.query.MatchAllQueryBuilder; |
30 | 27 | import org.elasticsearch.index.query.TermQueryBuilder; |
31 | 28 | import org.elasticsearch.license.LicenseSettings; |
32 | 29 | import org.elasticsearch.plugins.Plugin; |
|
40 | 37 |
|
41 | 38 | import java.io.IOException; |
42 | 39 | import java.time.Instant; |
43 | | -import java.util.Arrays; |
44 | 40 | import java.util.Collection; |
45 | | -import java.util.Comparator; |
46 | 41 | import java.util.List; |
47 | 42 | import java.util.UUID; |
48 | 43 | import java.util.concurrent.ExecutionException; |
49 | 44 |
|
50 | | -import static org.elasticsearch.index.query.QueryBuilders.matchQuery; |
51 | 45 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse; |
52 | 46 | import static org.hamcrest.Matchers.*; |
53 | 47 |
|
@@ -120,9 +114,7 @@ public void testGetByGeneratedId() throws Exception { |
120 | 114 | for (int j = 0; j < numDocs; j++) { |
121 | 115 | var indexRequest = new IndexRequest(dataStreamName).opType(DocWriteRequest.OpType.CREATE); |
122 | 116 | indexRequest.source( |
123 | | - DOC.replace("$time", formatInstant(time)) |
124 | | - .replace("$uuid", UUID.randomUUID().toString()) |
125 | | - .replace("$pod", "pod-" + j), |
| 117 | + DOC.replace("$time", formatInstant(time)).replace("$uuid", UUID.randomUUID().toString()).replace("$pod", "pod-" + j), |
126 | 118 | XContentType.JSON |
127 | 119 | ); |
128 | 120 | bulkRequest.add(indexRequest); |
@@ -160,13 +152,9 @@ public void testGetByProvidedID() throws Exception { |
160 | 152 | BulkRequest bulkRequest = new BulkRequest(indexName); |
161 | 153 | int numDocs = randomIntBetween(16, 256); |
162 | 154 | for (int j = 0; j < numDocs; j++) { |
163 | | - var indexRequest = new IndexRequest(indexName) |
164 | | - .opType(DocWriteRequest.OpType.INDEX) |
165 | | - .id("id-" + j); |
| 155 | + var indexRequest = new IndexRequest(indexName).opType(DocWriteRequest.OpType.INDEX).id("id-" + j); |
166 | 156 | indexRequest.source( |
167 | | - DOC.replace("$time", formatInstant(time)) |
168 | | - .replace("$uuid", UUID.randomUUID().toString()) |
169 | | - .replace("$pod", "pod-" + j), |
| 157 | + DOC.replace("$time", formatInstant(time)).replace("$uuid", UUID.randomUUID().toString()).replace("$pod", "pod-" + j), |
170 | 158 | XContentType.JSON |
171 | 159 | ); |
172 | 160 | bulkRequest.add(indexRequest); |
@@ -215,13 +203,9 @@ public void testMatchByProvidedID() throws Exception { |
215 | 203 | BulkRequest bulkRequest = new BulkRequest(indexName); |
216 | 204 | int numDocs = randomIntBetween(16, 256); |
217 | 205 | for (int j = 0; j < numDocs; j++) { |
218 | | - var indexRequest = new IndexRequest(indexName) |
219 | | - .opType(DocWriteRequest.OpType.INDEX) |
220 | | - .id("id-" + j); |
| 206 | + var indexRequest = new IndexRequest(indexName).opType(DocWriteRequest.OpType.INDEX).id("id-" + j); |
221 | 207 | indexRequest.source( |
222 | | - DOC.replace("$time", formatInstant(time)) |
223 | | - .replace("$uuid", UUID.randomUUID().toString()) |
224 | | - .replace("$pod", "pod-" + j), |
| 208 | + DOC.replace("$time", formatInstant(time)).replace("$uuid", UUID.randomUUID().toString()).replace("$pod", "pod-" + j), |
225 | 209 | XContentType.JSON |
226 | 210 | ); |
227 | 211 | bulkRequest.add(indexRequest); |
@@ -259,7 +243,6 @@ private void createTemplate(String dataStreamName) throws IOException { |
259 | 243 | client().execute(TransportPutComposableIndexTemplateAction.TYPE, putTemplateRequest).actionGet(); |
260 | 244 | } |
261 | 245 |
|
262 | | - |
263 | 246 | private void checkIndexSearchAndRetrieval(String dataStreamName, boolean routeOnSortFields) throws Exception { |
264 | 247 | String[] uuis = { |
265 | 248 | UUID.randomUUID().toString(), |
@@ -331,9 +314,7 @@ static String formatInstant(Instant instant) { |
331 | 314 | public void flush(String index, boolean force) throws IOException, ExecutionException, InterruptedException { |
332 | 315 | logger.info("flushing index {} force={}", index, force); |
333 | 316 | FlushRequest flushRequest = new FlushRequest(index).force(force); |
334 | | - assertResponse(client().admin().indices().flush(flushRequest), response -> { |
335 | | - assertEquals(0, response.getFailedShards()); |
336 | | - }); |
| 317 | + assertResponse(client().admin().indices().flush(flushRequest), response -> { assertEquals(0, response.getFailedShards()); }); |
337 | 318 | } |
338 | 319 |
|
339 | 320 | } |
0 commit comments