-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Fix logsdb settings provider mapping filters #136119
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
jordan-powers
merged 7 commits into
elastic:main
from
jordan-powers:fix-logsdb-settings-provider-mapping-filters
Oct 8, 2025
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d24c40f
Add tests reproducing issue
jordan-powers fae8ec6
Update mapping filters to optionally include _doc
jordan-powers f06b46e
Update docs/changelog/136119.yaml
jordan-powers 7d6504b
Remove PatternTextBasicLicenseTests
jordan-powers 36321f6
Merge remote-tracking branch 'upstream/main' into fix-logsdb-settings…
jordan-powers 52249dd
Merge remote-tracking branch 'upstream/main' into fix-logsdb-settings…
jordan-powers f7c47a5
Merge remote-tracking branch 'upstream/main' into fix-logsdb-settings…
jordan-powers 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
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,6 @@ | ||
pr: 136119 | ||
summary: Fix logsdb settings provider mapping filters | ||
area: Logs | ||
type: bug | ||
issues: | ||
- 136107 |
75 changes: 75 additions & 0 deletions
75
...estTest/java/org/elasticsearch/xpack/logsdb/patterntext/PatternTextBasicLicenseTests.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,75 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.logsdb.patterntext; | ||
|
||
import org.elasticsearch.xpack.logsdb.DataStreamLicenseChangeTestCase; | ||
import org.junit.Before; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.hasEntry; | ||
import static org.hamcrest.Matchers.hasKey; | ||
|
||
public class PatternTextBasicLicenseTests extends DataStreamLicenseChangeTestCase { | ||
@Before | ||
public void checkClusterFeature() { | ||
assumeTrue("[patterned_text] must be available", clusterHasFeature("mapper.patterned_text")); | ||
} | ||
|
||
private static final String patternTextMapping = """ | ||
{ | ||
"index_patterns": ["%name%"], | ||
"priority": 500, | ||
"data_stream": {}, | ||
"template": { | ||
"mappings": { | ||
"properties": { | ||
"pattern_field": { | ||
"type": "pattern_text" | ||
} | ||
} | ||
} | ||
} | ||
}"""; | ||
|
||
@SuppressWarnings("unchecked") | ||
public void testLicenseUpgrade() throws IOException { | ||
final String dataStreamName = "test-foo"; | ||
|
||
final String doc = """ | ||
{"index": {}} | ||
{"@timestamp": "2025-01-01T00:00:00.000Z", "pattern_field": "foo"} | ||
"""; | ||
|
||
assertOK(putTemplate(client(), "logs@custom", patternTextMapping.replace("%name%", dataStreamName))); | ||
assertOK(bulkIndex(client(), dataStreamName, () -> doc)); | ||
|
||
String backingIndex0 = getDataStreamBackingIndex(client(), dataStreamName, 0); | ||
{ | ||
assertEquals("true", getSetting(client(), backingIndex0, "index.mapping.pattern_text.disable_templating")); | ||
Map<String, Object> mapping = getMapping(client(), backingIndex0); | ||
Map<String, Object> patternFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
"pattern_field" | ||
); | ||
assertThat(patternFieldMapping, hasEntry("disable_templating", true)); | ||
} | ||
|
||
assertOK(rolloverDataStream(client(), dataStreamName)); | ||
|
||
String backingIndex1 = getDataStreamBackingIndex(client(), dataStreamName, 1); | ||
{ | ||
assertEquals("true", getSetting(client(), backingIndex1, "index.mapping.pattern_text.disable_templating")); | ||
Map<String, Object> mapping = getMapping(client(), backingIndex1); | ||
Map<String, Object> patternFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
"pattern_field" | ||
); | ||
assertThat(patternFieldMapping, hasKey("disable_templating")); | ||
} | ||
} | ||
} |
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.
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 one seems orthogonal.. let's leave it outside, to simplify backporting.
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 added this test because the logic to gate pattern_text behind a basic license also depends on the mapping (to detect if pattern_text is in use), and so it was also suffering from this same bug. But I'll move the test into a follow-up PR.