Skip to content

Add hook to provide settings and custom index metadata on mapping update#133232

Merged
felixbarny merged 16 commits intoelastic:mainfrom
felixbarny:main
Aug 25, 2025
Merged

Add hook to provide settings and custom index metadata on mapping update#133232
felixbarny merged 16 commits intoelastic:mainfrom
felixbarny:main

Conversation

@felixbarny
Copy link
Copy Markdown
Member

Part of #132566

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label external-contributor Pull request authored by a developer outside the Elasticsearch team v9.2.0 labels Aug 20, 2025
@felixbarny felixbarny added >non-issue :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. labels Aug 20, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Data Management (obsolete) DO NOT USE. This team no longer exists. label Aug 20, 2025
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Aug 20, 2025
@dakrone dakrone self-requested a review August 20, 2025 15:25
@felixbarny
Copy link
Copy Markdown
Member Author

As suggested by @dakrone, I’ll look into using custom index metadata instead of a private setting for my use case. If that approach works out well, I’ll probably enhance the settings provider interface so that it can provide custom index metadata when an index is created or updated.

@felixbarny
Copy link
Copy Markdown
Member Author

@dakrone thanks again for the suggestion. I've prototyped the approach in the context of #132566 and I like it lot better compared to the private index setting. It also avoids having to add infrastructure to allow providing private index settings when they're system-provided.

I was also considering whether to expose the full IndexMetadata.Builder to IndexSettingProvider and use a real index metadata field rather than custom metadata. But that seems more controversial as it makes the IndexSettingProvider more powerful than it needs to be which makes it harder to reason about failure domains. For example, it could then directly add index settings, bypassing some of the validation that we're doing today agains the returned index settings. Also, it would require to adjust the serialization logic.

I admit it's a bit weird that the class called IndexSettingProvider can now effectively also provide custom metadata. Maybe we could think about a new name but maybe it's also fine to live with that slight cognitive dissonance. I've also considered creating a new interface, or at least new methods that return a custom metadata map. However, the logic in #132566 needs to set the dimensions either as an index.routing_path setting, or as a custom metadata, depending on whether the path matches all potential dimension fields. So splitting this into two methods would be very awkward.

@felixbarny felixbarny changed the title Add hook to provide settings on mapping update Add hook to provide settings and custom index metadata on mapping update Aug 21, 2025
Copy link
Copy Markdown
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that we have both a return value and a passed in builder. I am on the fence about switching it to return void and instead passing in both the map builder and settings builder. I also wish we had a builder that was collection-compatible instead of using ImmutableOpenMap (though I understand why you used it).

But, I don't think those things need to hold this up, as they could be changed in the future transparently and without any breaking changes, so LGTM.

@felixbarny felixbarny requested a review from a team as a code owner August 22, 2025 05:37
@felixbarny
Copy link
Copy Markdown
Member Author

I don't love that we have both a return value and a passed in builder. I am on the fence about switching it to return void and instead passing in both the map builder and settings builder.

I don't like it either. I gave it a shot and make the refactoring. It's a lot better IMO. It's mostly mechanical changes that IntelliJ could assist me with. I also think it simplifies the control flow of existing implementations like LogsdbIndexModeSettingsProvider#getAdditionalIndexSettings.

I also wish we had a builder that was collection-compatible instead of using ImmutableOpenMap (though I understand why you used it).

I've changed it to a BiConsumer<String, Map<String, String>> now and I like it a little better.

@felixbarny
Copy link
Copy Markdown
Member Author

I've reverted the changes to server/src/main/java/org/elasticsearch/common/settings, removing core-infra as reviewer.

@felixbarny felixbarny removed the request for review from a team August 22, 2025 05:49
@felixbarny felixbarny mentioned this pull request Aug 22, 2025
@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Aug 22, 2025
Copy link
Copy Markdown
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM, I left one comment about naming suggestion, and another minor curiosity comment.

@felixbarny felixbarny enabled auto-merge (squash) August 25, 2025 05:44
@felixbarny felixbarny self-assigned this Aug 25, 2025
@felixbarny felixbarny merged commit 61c2bf1 into elastic:main Aug 25, 2025
33 checks passed
felixbarny added a commit to felixbarny/elasticsearch that referenced this pull request Sep 23, 2025
In elastic#133232, we've added the ability to provide index metadata with an IndexSettingProvider.
It turned out that we don't need that functionality as we ended up using a private index setting in elastic#132566.

This also adds the `IndexVersion` as another parameter. This is in preparation for [this](elastic#132566 (comment)) suggestion to conditionally set one or another setting, depending on the index version.
felixbarny added a commit that referenced this pull request Sep 24, 2025
In #133232, we've added the ability to provide index metadata with an IndexSettingProvider.
It turned out that we don't need that functionality as we ended up using a private index setting in #132566.

This also adds the `IndexVersion` as another parameter. This is in preparation for [this](#132566 (comment)) suggestion to conditionally set one or another setting, depending on the index version.

`IndexSettingProvider`s are now disallowed from providing the `index.version.created` setting. Otherwise, they can't rely on the `IndexVersion` they receive to be the one that will be actually used for the created index as another provider may change it.
breskeby pushed a commit to breskeby/elasticsearch that referenced this pull request Feb 11, 2026
breskeby pushed a commit to breskeby/elasticsearch that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue serverless-linked Added by automation, don't add manually Team:Data Management (obsolete) DO NOT USE. This team no longer exists. v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants