-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Create SPI to allow prohibiting certain top-level mappings #132360
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
Merged
quux00
merged 20 commits into
elastic:main
from
quux00:cross-project/prohibit-_project-mappings
Sep 19, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6c7575e
Init commit: same as cps/prohibit-_project-mappings branch
quux00 5c0c7ea
Most manual tests now pass. The two that still don't work right are:
quux00 f931cef
Hardcoded hack to get runtime fields with _project mappings to be det…
quux00 0350cac
Refactored validateNamespace signature so that RootObjectMapper.proce…
quux00 71f2156
Added namespaceValidator check to IndexService.parseRuntimeMappings
quux00 53ac90f
Changed runtime field validation to be done in one place: RuntimeFiel…
quux00 4eb29e2
Removed redundant call to mapper.validate(mappers) in ObjectMapper.va…
quux00 020f7ca
Initial set of tests for index time mappings - both standard and runt…
quux00 0cd6b97
Added query-time runtime field tests with RootObjectMapperNamespaceVa…
quux00 63c4549
Initial cleanup for PR review
quux00 af4964f
Cleanup for PR review - ready for next round review
quux00 ebaf9a2
Got subobjects:false tests working in RootObjectMapperTests
quux00 0aa546b
Merge remote-tracking branch 'elastic/main' into cross-project/prohib…
quux00 a8fcc03
Removed ServerlessRootObjectMapperNamespaceValidator
quux00 8665113
Fixed checkstyle issue
quux00 8843a78
Merge remote-tracking branch 'elastic/main' into cross-project/prohib…
quux00 ab5d0c2
Improved code comments
quux00 1524439
Merge remote-tracking branch 'elastic/main' into cross-project/prohib…
quux00 5b90e78
Merge remote-tracking branch 'elastic/main' into cross-project/prohib…
quux00 6ac6566
Merge remote-tracking branch 'elastic/main' into cross-project/prohib…
quux00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...c/main/java/org/elasticsearch/index/mapper/DefaultRootObjectMapperNamespaceValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.index.mapper; | ||
|
|
||
| /** | ||
| * No-op Default of RootObjectMapperNamespaceValidator used in non-serverless Elasticsearch envs. | ||
| */ | ||
| public class DefaultRootObjectMapperNamespaceValidator implements RootObjectMapperNamespaceValidator { | ||
| @Override | ||
| public void validateNamespace(ObjectMapper.Subobjects subobjects, String name) {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapperNamespaceValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.index.mapper; | ||
|
|
||
| import org.elasticsearch.core.Nullable; | ||
|
|
||
| /** | ||
| * SPI to inject additional rules around namespaces (top level fields) that are prohibited | ||
| * in Elasticsearch mappings. | ||
| */ | ||
| public interface RootObjectMapperNamespaceValidator { | ||
| /** | ||
| * If the namespace in the mapper is not allowed, an Exception should be thrown. | ||
| * @param subobjects Whether subobjects are enabled. Null is allowed | ||
| * @param name namespace (field name) to validate | ||
| */ | ||
| void validateNamespace(@Nullable ObjectMapper.Subobjects subobjects, String name); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.