|
44 | 44 | import java.util.Collection; |
45 | 45 | import java.util.List; |
46 | 46 | import java.util.function.Consumer; |
| 47 | +import java.util.function.UnaryOperator; |
47 | 48 |
|
48 | 49 | import static org.hamcrest.Matchers.equalTo; |
49 | 50 | import static org.hamcrest.Matchers.hasSize; |
@@ -130,7 +131,7 @@ public void testHostnameMessageTimestampSortConfig() throws IOException { |
130 | 131 | doc("{\"@timestamp\":\"2025-01-01T12:00:00\",\"test_id\": \"%id%\"}"), |
131 | 132 | doc("{\"@timestamp\":\"2025-01-01T11:00:00\",\"test_id\": \"%id%\"}") }; |
132 | 133 |
|
133 | | - createDataStream(dataStreamName, mapping); |
| 134 | + createDataStream(dataStreamName, mapping, b -> b.put("index.logsdb.default_sort_on_message_template", true)); |
134 | 135 |
|
135 | 136 | List<DocWithId> shuffledDocs = shuffledList(Arrays.asList(orderedDocs)); |
136 | 137 | indexDocuments(dataStreamName, shuffledDocs); |
@@ -264,11 +265,21 @@ public void testTimestampOnlySortConfig() throws IOException { |
264 | 265 | } |
265 | 266 |
|
266 | 267 | private void createDataStream(String dataStreamName, String mapping) throws IOException { |
| 268 | + createDataStream(dataStreamName, mapping, UnaryOperator.identity()); |
| 269 | + } |
| 270 | + |
| 271 | + private void createDataStream(String dataStreamName, String mapping, UnaryOperator<Settings.Builder> settings) throws IOException { |
267 | 272 | var putTemplateRequest = new TransportPutComposableIndexTemplateAction.Request("id"); |
268 | 273 | putTemplateRequest.indexTemplate( |
269 | 274 | ComposableIndexTemplate.builder() |
270 | 275 | .indexPatterns(List.of(dataStreamName + "*")) |
271 | | - .template(new Template(indexSettings(1, 0).put("index.mode", "logsdb").build(), new CompressedXContent(mapping), null)) |
| 276 | + .template( |
| 277 | + new Template( |
| 278 | + settings.apply(indexSettings(1, 0)).put("index.mode", "logsdb").build(), |
| 279 | + new CompressedXContent(mapping), |
| 280 | + null |
| 281 | + ) |
| 282 | + ) |
272 | 283 | .dataStreamTemplate(new ComposableIndexTemplate.DataStreamTemplate(false, false)) |
273 | 284 | .build() |
274 | 285 | ); |
|
0 commit comments