-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(search): resolve entity-specific aliases to canonical index names #27813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,6 +275,68 @@ void indexNameHelpersRespectClusterAlias() { | |
| "table_search_index", repository.getIndexNameWithoutAlias("cluster_table_search_index")); | ||
| } | ||
|
|
||
| /** | ||
| * Bug regression for issue #27761: passing the entity-specific alias {@code "table"} used to | ||
| * leak into ES alias expansion and surface tableColumn docs (because column_search_index is | ||
| * registered with {@code "table"} as one of its aliases). Resolving the alias to its canonical | ||
| * index name here bypasses ES's alias resolution, so the search hits exactly the table index. | ||
| */ | ||
| @Test | ||
| void getIndexOrAliasNameResolvesEntitySpecificAliasToCanonicalIndex() { | ||
| assertEquals("cluster_table_search_index", repository.getIndexOrAliasName("table")); | ||
| assertEquals("cluster_domain_search_index", repository.getIndexOrAliasName("domain")); | ||
| } | ||
|
|
||
| /** | ||
| * Compound aliases like {@code "all"} and {@code "dataAsset"} have no entry in | ||
| * {@code entityIndexMap} (they're meta-aliases registered against many entities at index | ||
| * creation time). The resolver passes them through with the cluster prefix so ES expands them | ||
| * natively — searching {@code dataAsset} should still surface every data-asset entity. | ||
| */ | ||
| @Test | ||
| void getIndexOrAliasNamePassesCompoundAliasesThroughForNativeESExpansion() { | ||
| assertEquals("cluster_dataAsset", repository.getIndexOrAliasName("dataAsset")); | ||
|
Comment on lines
+284
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Edge Case: No test coverage for non-clustered (null/empty clusterAlias) pathAll new tests in Suggested fix: Was this helpful? React with 👍 / 👎 | Reply |
||
| assertEquals("cluster_all", repository.getIndexOrAliasName("all")); | ||
| } | ||
|
|
||
| /** | ||
| * Defense-in-depth: a token that already carries the cluster prefix must not get prefixed | ||
| * again. Otherwise multi-tenant deployments would 404 on | ||
| * {@code cluster_cluster_table_search_index} if any internal code accidentally hands a | ||
| * resolved value back to this method. | ||
| */ | ||
| @Test | ||
| void getIndexOrAliasNameIsIdempotentForAlreadyPrefixedTokens() { | ||
| assertEquals( | ||
| "cluster_table_search_index", repository.getIndexOrAliasName("cluster_table_search_index")); | ||
| } | ||
|
|
||
| /** | ||
| * Mixed input: each comma-separated token is resolved independently. Entity-specific aliases | ||
| * resolve to canonical names; compound aliases pass through. | ||
| */ | ||
| @Test | ||
| void getIndexOrAliasNameResolvesEachCommaSeparatedTokenIndependently() { | ||
| assertEquals( | ||
| "cluster_table_search_index,cluster_dataAsset", | ||
| repository.getIndexOrAliasName("table,dataAsset")); | ||
| } | ||
|
|
||
| /** | ||
| * Stray-comma / empty-token input must not produce bare cluster prefixes such as | ||
| * {@code "cluster_"}. Empty tokens are dropped; if every token is empty the original string | ||
| * is returned unchanged so downstream ES surfaces a normal "unknown index" error instead of | ||
| * a confusing empty-target failure. | ||
| */ | ||
| @Test | ||
| void getIndexOrAliasNameDropsEmptyTokensAndPreservesAllEmptyInput() { | ||
| assertEquals("cluster_table_search_index", repository.getIndexOrAliasName("table,")); | ||
| assertEquals( | ||
| "cluster_table_search_index,cluster_domain_search_index", | ||
| repository.getIndexOrAliasName("table, ,domain")); | ||
| assertEquals(", ,", repository.getIndexOrAliasName(", ,")); | ||
| } | ||
|
|
||
| @Test | ||
| void indexExistsFallsBackToAliasLookup() { | ||
| when(searchClient.indexExists("cluster_table_search_index")).thenReturn(false); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.