Skip to content

Conversation

jordan-powers
Copy link
Contributor

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

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

Copy link
Member

@martijnvg martijnvg left a 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);
Copy link
Member

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.

@jordan-powers jordan-powers merged commit e9c2510 into elastic:main Sep 29, 2025
34 of 35 checks passed
@jordan-powers jordan-powers deleted the disable-unlicensed-pattern-text-only-when-used branch October 1, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants