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