|
7 | 7 |
|
8 | 8 | package org.elasticsearch.xpack.esql.action; |
9 | 9 |
|
| 10 | +import org.apache.lucene.tests.util.LuceneTestCase; |
10 | 11 | import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; |
| 12 | +import org.elasticsearch.action.index.IndexRequestBuilder; |
11 | 13 | import org.elasticsearch.common.settings.Settings; |
12 | 14 | import org.elasticsearch.index.mapper.extras.MapperExtrasPlugin; |
13 | 15 | import org.elasticsearch.plugins.Plugin; |
14 | 16 | import org.elasticsearch.test.ESIntegTestCase; |
15 | 17 | import org.elasticsearch.test.ESIntegTestCase.ClusterScope; |
| 18 | +import org.elasticsearch.xcontent.XContentType; |
16 | 19 | import org.elasticsearch.xpack.core.esql.action.ColumnInfo; |
17 | 20 | import org.elasticsearch.xpack.esql.VerificationException; |
18 | 21 | import org.elasticsearch.xpack.esql.core.type.DataType; |
|
76 | 79 | * E.g. the field {@code main_byte} will occur another time in the index {@code main_byte_as_short} when we're testing a byte-short union |
77 | 80 | * type. |
78 | 81 | */ |
| 82 | +// TODO: This suite creates a lot of indices. It should be sufficient to just create 1 main index with 1 field per relevant type and 1 |
| 83 | +// lookup index with 1 field per relevant type; only union types require additional main indices so we can have the same field mapped to |
| 84 | +// different types. |
| 85 | +@LuceneTestCase.SuppressFileSystems(value = "HandleLimitFS") |
79 | 86 | @ClusterScope(scope = SUITE, numClientNodes = 1, numDataNodes = 1) |
80 | 87 | public class LookupJoinTypesIT extends ESIntegTestCase { |
81 | 88 | private static final String MAIN_INDEX_PREFIX = "main_"; |
@@ -322,10 +329,14 @@ private void initIndexes(TestConfigs configs) { |
322 | 329 | } |
323 | 330 |
|
324 | 331 | private void initData(TestConfigs configs) { |
325 | | - for (TestDocument doc : configs.docs()) { |
326 | | - index(doc.indexName, doc.id, doc.source); |
327 | | - refresh(doc.indexName); |
| 332 | + List<TestDocument> docs = configs.docs(); |
| 333 | + List<IndexRequestBuilder> indexRequests = new ArrayList<>(docs.size()); |
| 334 | + |
| 335 | + for (TestDocument doc : docs) { |
| 336 | + var indexRequest = client().prepareIndex().setIndex(doc.indexName()).setId(doc.id).setSource(doc.source, XContentType.JSON); |
| 337 | + indexRequests.add(indexRequest); |
328 | 338 | } |
| 339 | + indexRandom(true, indexRequests); |
329 | 340 | } |
330 | 341 |
|
331 | 342 | private static String propertyFor(String fieldName, DataType type) { |
|
0 commit comments