Skip to content
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

[8.x] IndexNameExpressionResolver refactoring (#116085) #117267

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from

Conversation

gmarouli
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

* Refactor DateMathExpressionResolver.

In this commit we reduce the scope of the DateMathExpressionResolver to only handle one expression at a time. This simplifies the code since it move the preprocessing from the date math calculation.

Furthermore, we simplify the API, so it does not need a context.

Finally, the reduced scope allowed us to reduce the test footprint. The tests are targeted only to the single expression date math resolution and any test with expression combinations will be moved to the IndexNameExpressionResolverTests.

* Create SystemResourceAccess.

In this class we collect all the related access checks to system indices.

These checks are not straight forward and there are different rules that apply on different parts of the code.

In this PR, we just collect them in one place to allow further analysis to determine if these differences are a feature or a bug.

* Refactor WildcardExpressionResolver.

In this PR we reduced the scope of the WildcardExpressionResolver to resolve one expression at a time. It also still supports the `*`.

This allows us to reduce the scope of the test as well.

Furthermore, we switched the usage of streams to more imperative code to reduce the object creation.

* Refactor expression resolution to resources.

In this PR we bring all the previous steps together. We change the expression resolution, instead of processing lists of expressions to completely resolve one expression to its resources before moving to the next.

This intends to increase the maintainability of the code, because we can debug it easier and we reduce the code duplication when dealing with exclusions and other pre-processing tasks.

* Fix format

* Bug fix: do the empty check on wildcard expressions on each wildcard

* Polishing

* Optimise for no wildcards

* Fix test name typo

* Replace for-each loops with for-i loops

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: James Baiera <[email protected]>
(cherry picked from commit 7dc2cc6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants