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

Add selector syntax to index expressions #118614

Merged
merged 113 commits into from
Jan 8, 2025

Conversation

jbaiera
Copy link
Member

@jbaiera jbaiera commented Dec 12, 2024

In order to make adoption of failure stores simpler for all users, we are introducing a new syntactical feature to index expression resolution: The selector.

Selectors, denoted with a :: followed by a recognized suffix will allow users to specify which component of an index abstraction they would like to operate on within an API call. In this case, an index abstraction is a concrete index, data stream, or alias; Any abstraction that can be resolved to a set of indices/shards. We define a component of an index abstraction to be some searchable unit of the index abstraction.

To start, we will support two components: data and failures. Concrete indices are their own data components, while the data component for index aliases are all of the indices contained therein. For data streams, the data component corresponds to their backing indices. Data stream aliases mirror this, treating all backing indices of the data streams they correspond to as their data component.

The failure component is only supported by data streams and data stream aliases. The failure component of these abstractions refer to the data streams' failure stores. Indices and index aliases do not have a failure component.

In order to select which components a user wants to operate on within an API call, the components are selected using the new selector syntax in an index expression:

GET my-data-stream::failures/_search

On supporting APIs, selector syntax is evaluated first in every index expression. The syntax only accepts a predefined list of selector names or the match all * wildcard. It does not support any other selector names and it does not support simple match syntax. Any unsupported usage of the selector syntax will raise an exception.

Examples:

// Accepted
my-data-stream::data // Resolves to the data stream's backing indices only
my-data-stream::failures // Resolves to the data stream's failure indices only
my-data-stream::* // Resolves to both the data stream's backing and failure indices

// Rejected
my-data-stream::d*ta // Simple match syntax is not supported
my-data-stream::custom // Syntax only accepts predefined selector names (currently `*`, `data`, and `failures`)

Selector syntax is compatible with other expression syntax like date math and wildcard matching of index names:

GET <logs-daily-{now/d}>::failures/_settings
GET logs-*::failures/_mappings
GET *::*,-logs-*::data/_search

Selector syntax will not be supported on every API as it does not always make sense. For example, the create and delete index APIs operate on indices only and will not support selectors. In these cases, any selector usage will raise an exception:

PUT logs-my-index::data // Raises exception because selector was used on unsupported API

API's that support selectors will default to using the ::data selector when selectors are not provided on an index expression. When evaluating expressions that have an explicit ::data selectors on them, the resolution code will translate the expressions back into names without selectors for consistency's sake.

This PR was reconstructed from #113144 which it supercedes.

jbaiera and others added 30 commits September 18, 2024 13:20
The logic is shimmed into place and will be updated in later commits to propagate its results to callers.
Add logic for handling the selectors in alias filter collection.
@jbaiera
Copy link
Member Author

jbaiera commented Jan 6, 2025

@elasticmachine run buildkite/docs-build-pr

jbaiera and others added 4 commits January 7, 2025 12:00
…ecurity/authz/IndicesAndAliasesResolver.java

Co-authored-by: Mary Gouseti <mgouseti@gmail.com>
…ecurity/authz/IndicesAndAliasesResolver.java

Co-authored-by: Mary Gouseti <mgouseti@gmail.com>
@jbaiera
Copy link
Member Author

jbaiera commented Jan 8, 2025

@elasticmachine run elasticsearch-ci/part-1

@jbaiera jbaiera added v8.18.0 auto-backport Automatically create backport pull requests when merged labels Jan 8, 2025
@jbaiera jbaiera merged commit c3839e1 into elastic:main Jan 8, 2025
16 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 118614

@jbaiera
Copy link
Member Author

jbaiera commented Jan 9, 2025

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

jbaiera added a commit to jbaiera/elasticsearch that referenced this pull request Jan 9, 2025
This PR introduces a new syntactical feature to index expression resolution: The selector.

Selectors, denoted with a :: followed by a recognized suffix will allow users to specify which component of
an index abstraction they would like to operate on within an API call. In this case, an index abstraction is a
concrete index, data stream, or alias; Any abstraction that can be resolved to a set of indices/shards. We
define a component of an index abstraction to be some searchable unit of the index abstraction.

(cherry picked from commit c3839e1)

# Conflicts:
#	modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java
#	server/src/main/java/org/elasticsearch/TransportVersions.java
#	server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java
@jbaiera jbaiera deleted the failure-store-naming-scheme branch January 9, 2025 15:56
jbaiera added a commit that referenced this pull request Jan 10, 2025
* Add selector syntax to index expressions (#118614)

This PR introduces a new syntactical feature to index expression resolution: The selector.

Selectors, denoted with a :: followed by a recognized suffix will allow users to specify which component of
an index abstraction they would like to operate on within an API call. In this case, an index abstraction is a
concrete index, data stream, or alias; Any abstraction that can be resolved to a set of indices/shards. We
define a component of an index abstraction to be some searchable unit of the index abstraction.

(cherry picked from commit c3839e1)

# Conflicts:
#	modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/IngestFailureStoreMetricsIT.java
#	server/src/main/java/org/elasticsearch/TransportVersions.java
#	server/src/test/java/org/elasticsearch/action/OriginalIndicesTests.java

* [CI] Auto commit changes from spotless

* Fixing compiler issues

* Remove feature flag from influencing the serialisation

* Only add failure indices when failure store flag is on

* Fix OriginalIndicesTests

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Co-authored-by: Felix Barnsteiner <felixbarny@users.noreply.github.com>
Co-authored-by: Mary Gouseti <mary.gouseti@elastic.co>
Co-authored-by: Mary Gouseti <mgouseti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending :Data Management/Data streams Data streams and their lifecycles >non-issue serverless-linked Added by automation, don't add manually Team:Data Management Meta label for data/management team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants