|
40 | 40 | import org.opensearch.common.Booleans;
|
41 | 41 | import org.opensearch.common.io.Streams;
|
42 | 42 | import org.opensearch.common.settings.Settings;
|
| 43 | +import org.opensearch.index.IndexSettings; |
43 | 44 | import org.opensearch.index.codec.CodecService;
|
44 | 45 | import org.opensearch.index.engine.EngineConfig;
|
45 | 46 | import org.opensearch.indices.replication.common.ReplicationType;
|
46 |
| -import org.opensearch.test.OpenSearchIntegTestCase; |
47 | 47 | import org.opensearch.test.rest.yaml.ObjectPath;
|
48 | 48 |
|
49 | 49 | import java.io.IOException;
|
@@ -344,6 +344,92 @@ public void testIndexingWithSegRep() throws Exception {
|
344 | 344 | }
|
345 | 345 | }
|
346 | 346 |
|
| 347 | + public void testIndexingWithFuzzyFilterPostings() throws Exception { |
| 348 | + if (UPGRADE_FROM_VERSION.onOrBefore(Version.V_2_11_1)) { |
| 349 | + logger.info("--> Skip test for version {} where fuzzy filter postings format feature is not available", UPGRADE_FROM_VERSION); |
| 350 | + return; |
| 351 | + } |
| 352 | + final String indexName = "test-index-fuzzy-set"; |
| 353 | + final int shardCount = 3; |
| 354 | + final int replicaCount = 1; |
| 355 | + logger.info("--> Case {}", CLUSTER_TYPE); |
| 356 | + printClusterNodes(); |
| 357 | + logger.info("--> _cat/shards before test execution \n{}", EntityUtils.toString(client().performRequest(new Request("GET", "/_cat/shards?v")).getEntity())); |
| 358 | + switch (CLUSTER_TYPE) { |
| 359 | + case OLD: |
| 360 | + Settings.Builder settings = Settings.builder() |
| 361 | + .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), shardCount) |
| 362 | + .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), replicaCount) |
| 363 | + .put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) |
| 364 | + .put( |
| 365 | + EngineConfig.INDEX_CODEC_SETTING.getKey(), |
| 366 | + randomFrom(new ArrayList<>(CODECS) { |
| 367 | + { |
| 368 | + add(CodecService.LUCENE_DEFAULT_CODEC); |
| 369 | + } |
| 370 | + }) |
| 371 | + ) |
| 372 | + .put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms"); |
| 373 | + createIndex(indexName, settings.build()); |
| 374 | + waitForClusterHealthWithNoShardMigration(indexName, "green"); |
| 375 | + bulk(indexName, "_OLD", 5); |
| 376 | + break; |
| 377 | + case MIXED: |
| 378 | + waitForClusterHealthWithNoShardMigration(indexName, "yellow"); |
| 379 | + break; |
| 380 | + case UPGRADED: |
| 381 | + Settings.Builder settingsBuilder = Settings.builder() |
| 382 | + .put(IndexSettings.INDEX_DOC_ID_FUZZY_SET_ENABLED_SETTING.getKey(), true); |
| 383 | + updateIndexSettings(indexName, settingsBuilder); |
| 384 | + waitForClusterHealthWithNoShardMigration(indexName, "green"); |
| 385 | + break; |
| 386 | + default: |
| 387 | + throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]"); |
| 388 | + } |
| 389 | + |
| 390 | + int expectedCount; |
| 391 | + switch (CLUSTER_TYPE) { |
| 392 | + case OLD: |
| 393 | + expectedCount = 5; |
| 394 | + break; |
| 395 | + case MIXED: |
| 396 | + if (Booleans.parseBoolean(System.getProperty("tests.first_round"))) { |
| 397 | + expectedCount = 5; |
| 398 | + } else { |
| 399 | + expectedCount = 10; |
| 400 | + } |
| 401 | + break; |
| 402 | + case UPGRADED: |
| 403 | + expectedCount = 15; |
| 404 | + break; |
| 405 | + default: |
| 406 | + throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]"); |
| 407 | + } |
| 408 | + |
| 409 | + waitForSearchableDocs(indexName, shardCount, replicaCount); |
| 410 | + assertCount(indexName, expectedCount); |
| 411 | + |
| 412 | + if (CLUSTER_TYPE != ClusterType.OLD) { |
| 413 | + bulk(indexName, "_" + CLUSTER_TYPE, 5); |
| 414 | + logger.info("--> Index one doc (to be deleted next) and verify doc count"); |
| 415 | + Request toBeDeleted = new Request("PUT", "/" + indexName + "/_doc/to_be_deleted"); |
| 416 | + toBeDeleted.addParameter("refresh", "true"); |
| 417 | + toBeDeleted.setJsonEntity("{\"f1\": \"delete-me\"}"); |
| 418 | + client().performRequest(toBeDeleted); |
| 419 | + waitForSearchableDocs(indexName, shardCount, replicaCount); |
| 420 | + assertCount(indexName, expectedCount + 6); |
| 421 | + |
| 422 | + logger.info("--> Delete previously added doc and verify doc count"); |
| 423 | + Request delete = new Request("DELETE", "/" + indexName + "/_doc/to_be_deleted"); |
| 424 | + delete.addParameter("refresh", "true"); |
| 425 | + client().performRequest(delete); |
| 426 | + waitForSearchableDocs(indexName, shardCount, replicaCount); |
| 427 | + assertCount(indexName, expectedCount + 5); |
| 428 | + |
| 429 | + //forceMergeAndVerify(indexName, shardCount * (1 + replicaCount)); |
| 430 | + } |
| 431 | + } |
| 432 | + |
347 | 433 | public void testAutoIdWithOpTypeCreate() throws IOException {
|
348 | 434 | final String indexName = "auto_id_and_op_type_create_index";
|
349 | 435 | StringBuilder b = new StringBuilder();
|
|
0 commit comments