@@ -671,23 +671,24 @@ public void testTrailingCommaInVectorRejected() throws IOException {
671671
672672 // ── Alias with multiple backing indices ───────────────────────────────
673673 // vectorSearch() accepts an alias as `table=`. When the alias points at multiple backing
674- // indices with matching knn_vector mappings, planning must succeed — the query then runs
675- // across all backing indices just like a regular alias query. Execution requires the k-NN
676- // plugin, which is not installed on the default integ-test cluster, so these tests verify
677- // the planning path via _explain only .
674+ // indices, planning must accept the alias string instead of treating it as a wildcard or
675+ // multi-target. Execution correctness over compatible knn_vector mappings is a separate
676+ // concern covered by k-NN-enabled tests/follow-up; these tests lock in planning acceptance
677+ // only, via _explain on the default no-kNN cluster .
678678
679679 @ Test
680680 public void testExplainOverAliasWithMultipleBackingIndices () throws IOException {
681681 // Create two indices with identical keyword mappings (no knn_vector, since the plugin is
682682 // not installed) and a shared alias. We only assert the planner accepts the alias; whether
683683 // k-NN accepts the alias at execution is a separate concern tested on a k-NN-enabled
684684 // cluster.
685- String idx1 = "vector_alias_backing_1" ;
686- String idx2 = "vector_alias_backing_2" ;
687- String alias = "vector_alias_combined" ;
685+ // Randomized names so a stale alias/index left by an aborted prior run of this class does
686+ // not shadow a fresh setup — a concrete risk on local reruns.
687+ String suffix = java .util .UUID .randomUUID ().toString ().replace ("-" , "" ).substring (0 , 8 );
688+ String idx1 = "vector_alias_backing_1_" + suffix ;
689+ String idx2 = "vector_alias_backing_2_" + suffix ;
690+ String alias = "vector_alias_combined_" + suffix ;
688691 try {
689- deleteIndexIfExists (idx1 );
690- deleteIndexIfExists (idx2 );
691692 createSimpleIndex (idx1 );
692693 createSimpleIndex (idx2 );
693694 addToAlias (idx1 , alias );
@@ -702,6 +703,9 @@ public void testExplainOverAliasWithMultipleBackingIndices() throws IOException
702703 assertThat (explain , containsString ("VectorSearchIndexScan" ));
703704 assertThat (explain , containsString (alias ));
704705 } finally {
706+ // Deleting the backing indices removes the alias automatically, but delete the alias
707+ // first for robustness against partial setup failures.
708+ deleteAliasIfExists (alias );
705709 deleteIndexIfExists (idx1 );
706710 deleteIndexIfExists (idx2 );
707711 }
@@ -731,4 +735,12 @@ private void deleteIndexIfExists(String indexName) {
731735 // Index does not exist, which is fine.
732736 }
733737 }
738+
739+ private void deleteAliasIfExists (String aliasName ) {
740+ try {
741+ client ().performRequest (new Request ("DELETE" , "/_all/_alias/" + aliasName ));
742+ } catch (IOException ignored ) {
743+ // Alias does not exist, which is fine.
744+ }
745+ }
734746}
0 commit comments