-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Disable dynamic/Implement static mappings #10638
Disable dynamic/Implement static mappings #10638
Conversation
config: { | ||
dynamic: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might be able to get away with enabled: false on this, thoughts? buildNum is used but otherwise we aren't searching
@Bargs Am I dreaming, or did you also take a swing at dynamic mappings in the past? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid having parallel mapping definitions in the codebase e.g.
const mapping = mappingSetup.expandShorthand({ |
@@ -1,16 +1,223 @@ | |||
export const mappings = { | |||
'_default_': { | |||
'dynamic': 'false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be strict
shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in de9d04a
'_default_': { | ||
'dynamic': 'false' | ||
}, | ||
dashboard: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like these mappings should be a part of each individual plugin's definition rather than crammed into the elasticsearch plugin, doesn't it? Feel free to ignore me if that's already the plan and this is just a stopgap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 working on this one now. The plan is to expose a registerMappings method on the elasticsearch plugin. I was concerned there could be timing issues when collecting these registrations, but it looks like it will work from the plugin's init method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 00cd9e0
@epixa nah, you might be thinking of the work I did on string -> text/keyword. |
Agree on removing client side mappings but I left them in for 5.x reasons. Currently these will only be applied if the Kibana index doesn't exist. If it already exists but doesn't have the full set of mappings we want the client side mappings to happen. I'd like some idempotent put mapping operation to happen on startup but we'll need to get the functionality in for reindexing .kibana at the same time. |
a872e9c
to
02e24fc
Compare
This has conflicts, FYI |
6cf51bd
to
a28b530
Compare
jenkins, test this |
1 similar comment
jenkins, test this |
}; | ||
|
||
export function assignMappings(mappings) { | ||
Object.assign(defaultMappings, mappings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we concerned with, or should we provide protections against, someone overwriting our properties stored in the mappings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 7f333ed
This needs to make sure that each mapping exists even before creating a .kibana index. If a user upgrades to this implementation after starting kibana but before saving a dashboard, or installs a new plugin which adds new mappings, the .kibana index won't have the correct mappings. |
a28b530
to
7f333ed
Compare
@spalger my thoughts were to address that with the later upgrade process. As it stands now, I left all of the client side code to create mappings if the type doesn't exist. Eventually the checks won't be needed with the upgrade process in place, so instead of transitioning the client side checks to the server I opted for not doing anything. A couple scenarios from this PR:
The only case this covers is plugins or services pushing visualizations, dashboards post startup, which isn't needed for 5.4. It's fairly low impact, but may be safer to roll together with the upgrade tool. Any thoughts on edge cases I'm missing? Or waiting to include this with a more thorough upgrade process? |
Jenkins, test it |
LGTM |
c46ee79
to
6adb460
Compare
* Disable dynamic mappings * Disable automatic type creation * Centralize .kibana mappings * Use dynamic strict instead of false * Register mappings per plugin * Check for registered mapping conflicts * Expose mappings on server scope instead of module * Stub elasticsearch mappings class * Add tests for KibanaMappings class * [mappings tests] to.an -> to.be.an * Return on mapping conflict and include plugin id if provided * [uiExports] Add mappings uiExport type * Use uiExports config in mappings tests * Clean up ui_mappings test * Revert plugin require ordering * Pull uiExports mappings from kibana object isntead of kbnServer
@jbudz Don't forget to backport this |
* Disable dynamic/Implement static mappings (#10638) * Disable dynamic mappings * Disable automatic type creation * Centralize .kibana mappings * Use dynamic strict instead of false * Register mappings per plugin * Check for registered mapping conflicts * Expose mappings on server scope instead of module * Stub elasticsearch mappings class * Add tests for KibanaMappings class * [mappings tests] to.an -> to.be.an * Return on mapping conflict and include plugin id if provided * [uiExports] Add mappings uiExport type * Use uiExports config in mappings tests * Clean up ui_mappings test * Revert plugin require ordering * Pull uiExports mappings from kibana object isntead of kbnServer * [test] Update index mapping to look for keyword
5.x: d5dda02 |
🎉 |
} | ||
} | ||
|
||
export { MappingsCollection }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, we should not export raw objects like this. This is not valid JavaScript, it's just something that babel supports because it happens to behave similarly to CommonJS modules. Export the class itself instead.
Currently Kibana creates most mappings for the .kibana index on the client as needed. This code is split up between separate applications, and in some cases mappings aren't defined. This makes it difficult for external tools or kibana plugins to push .kibana data with correct mappings and can cause unexpected errors. In 6.0 we will also need to reindex and a complete definition will help with this.
When a new .kibana index is created, this disables dynamic mappings for everything except .kibana/config, disables dynamic type creation, and pushes all mappings.
Scenarios from this PR:
Closes #4964