-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Only disable unlicensed pattern_text templating when mapper is used #135561
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
Only disable unlicensed pattern_text templating when mapper is used #135561
Conversation
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
If my comment about MappingVisitor
works out, then it makes sense to do this change instead of #135553.
for (CompressedXContent mappingSource : combinedTemplateMappings) { | ||
var ref = mappingSource.compressedReference(); | ||
if (maybeUsesPatternText == false) { | ||
maybeUsesPatternText = mappingSource.string().contains(PatternTextFieldType.CONTENT_TYPE); |
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.
I think that just checking whether mapping contains pattern_text
string can also give false positives. For example if field name is named pattern_text
. We would need to search for "type":"pattern_text"
, but we would need to be lenient with whitespaces.
Maybe instead we should MappingVisitor
here after line 268. Then we already parsed the mapping as a map. Then checking for type
key with pattern_text
value is less error prone.
Currently we always set the
index.mapping.pattern_text.disable_templating
setting for every standard-mode index.This is a bit excessive, so this PR updates the logic to only include the setting if pattern_text field mappers are in use.
Instantiating a whole mapper service just to check for the existence of a PatternedTextMapper would be fairly expensive. So instead this patch simply checks the mapping source for the string "pattern_text". While there may be some false positives, the only overhead of a false positive is that a single index setting is set and then ignored.
This is an alternate approach to #135553