Support recording index resolution results on IndicesRequest#134783
Support recording index resolution results on IndicesRequest#134783elasticsearchmachine merged 12 commits intoelastic:mainfrom
IndicesRequest#134783Conversation
…icsearch into cps-index-expressions-model
ReplacedIndexExpressions modelResolvedIndexExpressions model
ResolvedIndexExpressions modelIndicesRequest
IndicesRequestIndicesRequest
|
Pinging @elastic/es-security (Team:Security) |
server/src/main/java/org/elasticsearch/action/ResolvedIndexExpression.java
Show resolved
Hide resolved
|
|
||
| /** | ||
| * Record the results of index resolution. See {@link ResolvedIndexExpressions} for details. | ||
| * Note: this method does not replace {@link #indices(String...)}. {@link #indices(String...)} must still be called to update |
There was a problem hiding this comment.
Nothing to do for this PR. But could you please remind me what the long term vision is for this new method and the existing indices(String ...indices) method? Did we align that the new one could eventually replace the existing one and as an interim the default implementation could call something like indices(expressions.getAllLocalIndices())? Or maybe something else? My memory is hazy on this one.
There was a problem hiding this comment.
My current plan for the interim is to maintain the methods separately and keep them independent. However, I'll still play around with the option of making a call like indices(expressions.getAllLocalIndices()) under the hood in the next PR where I plug this into the indices resolver.
Long term, the plan is to consolidate the two methods (replace indices(...)). That's a bigger refactor but seems very worthwhile since it'll move us closer to having structured info about index resources as opposed to opaque strings.
server/src/main/java/org/elasticsearch/action/ResolvedIndexExpressions.java
Show resolved
Hide resolved
This PR extends index resolution logic to capture the resolution mapping from original to resolution result via `ResolvedIndexExpressions` (introduced in #134783). This lets consumers such as cross-project search that require full resolution context to access it via the `IndicesRequest.Replaceable` interface. To maximize code re-use, the PR updates the existing `resolveIndexAbstractions` method to always return a `ResolvedIndexExpressions` instance. The result is only recorded on the request if a boolean flag is set to avoid unnecessary memory overhead in contexts where storing the expressions is not necessary. In a (much bigger) future refactor, we plan to move away from storing a raw indices list and always use `ResolvedIndexExpressions` as the source of truth for indices resources accessed by a request. Once that's complete, we will move to _always_ storing the full resolution result. This PR does not include the following, which we'll address in immediate follow ups: - Integrate the change into the wider implementation of cross-project search index expressions rewriting and error handling - Store resolution for `_all` index expression handling - Record full authorization exceptions on authorization failures - Record resolution for remote expressions (e.g., `p:logs -> p1:logs`) Relates: ES-12690
This PR introduces
ResolvedIndexExpressionandResolvedIndexExpressionsclasses to capture context about index resolution (local results, exceptions, and unresolved remote expressions).IndicesRequest.Replaceablenow provides optional methods to set and retrieve resolved index expressions, enabling requests to carry richer resolution metadata alongside the existingindices(...)API.Follow up work will plug this class into
IndicesAndAliasesResolver.This change is motivated by the requirements around error handling for cross-project search where error handling is performed post local index resolution in some cases.
Closes: ES-12688