-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add disable_templating index setting/mapping parameter to patterned_text #134466
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 24 commits into
elastic:main
from
jordan-powers:patterned-text-licensing
Sep 16, 2025
Merged
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
89a1263
Add fallbackToMatchOnlyText flag to PatternedTextFieldMapper
jordan-powers a8289cb
Include settings defined in plugins in MapperServiceTestCase#createMa…
jordan-powers d52ea6d
Add tests for fallbackToMatchOnlyText
jordan-powers 706718e
Create DataStreamLicenseChangeTestCase base class
jordan-powers 3cabb61
Add integration tests for patterned_text license upgrade/downgrade
jordan-powers 8de8d0f
Make DataStreamLicenseChangeTestCase abstract
jordan-powers 0020f48
Pass up license to XPackPlugin in LocalStateCompositeXPackPlugin
jordan-powers 061c8d4
Update LogsdbIndexSettingsProviderLegacyLicenseTests
jordan-powers 6f7a5a8
Rename settings
jordan-powers 162a38a
Clean up comments
jordan-powers c1c63d4
Disable PatternedTextLicense tests in non-snapshot builds
jordan-powers d97bf2c
Merge remote-tracking branch 'upstream/main' into patterned-text-lice…
jordan-powers 00f8341
Add missed rename
jordan-powers 0860b3e
Add LocalStateLogsdb subclass of LocalStateCompositeXPackPlugin
jordan-powers 051c545
Rename patterned_text_disable_enterprise to patterned_text.disable_te…
jordan-powers 6797e8b
Change patterned_text.disable_templating index setting scope to Priva…
jordan-powers 3ea06e5
Merge remote-tracking branch 'upstream/main' into patterned-text-lice…
jordan-powers 21c06de
Fix failing tests
jordan-powers 2e06c2d
Revert "Add LocalStateLogsdb subclass of LocalStateCompositeXPackPlugin"
jordan-powers 329b243
Merge remote-tracking branch 'upstream/main' into patterned-text-lice…
jordan-powers f4b7aa7
Move disableTemplating flag to PatternedTextFieldType
jordan-powers 5cf3b93
Fix typo in comment
jordan-powers 96543e1
Merge remote-tracking branch 'upstream/main' into patterned-text-lice…
jordan-powers 76ae5b1
Merge remote-tracking branch 'upstream/main' into patterned-text-lice…
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
45 changes: 45 additions & 0 deletions
45
...src/javaRestTest/java/org/elasticsearch/xpack/logsdb/DataStreamLicenseChangeTestCase.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,45 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
| import org.elasticsearch.test.cluster.local.distribution.DistributionType; | ||
| import org.junit.ClassRule; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public abstract class DataStreamLicenseChangeTestCase extends LogsIndexModeRestTestIT { | ||
| @ClassRule | ||
| public static ElasticsearchCluster cluster = ElasticsearchCluster.local() | ||
| .distribution(DistributionType.DEFAULT) | ||
| .module("data-streams") | ||
| .module("x-pack-stack") | ||
| .setting("cluster.logsdb.enabled", "true") | ||
| .setting("xpack.security.enabled", "false") | ||
| .setting("xpack.license.self_generated.type", "basic") | ||
| .build(); | ||
|
|
||
| @Override | ||
| protected String getTestRestCluster() { | ||
| return cluster.getHttpAddresses(); | ||
| } | ||
|
|
||
| protected static void startBasic() throws IOException { | ||
| Request startTrial = new Request("POST", "/_license/start_basic"); | ||
| startTrial.addParameter("acknowledge", "true"); | ||
| assertOK(client().performRequest(startTrial)); | ||
| } | ||
|
|
||
| protected static void startTrial() throws IOException { | ||
| Request startTrial = new Request("POST", "/_license/start_trial"); | ||
| startTrial.addParameter("acknowledge", "true"); | ||
| assertOK(client().performRequest(startTrial)); | ||
| } | ||
|
|
||
| } |
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
82 changes: 82 additions & 0 deletions
82
...st/java/org/elasticsearch/xpack/logsdb/patternedtext/PatternedTextLicenseDowngradeIT.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,82 @@ | ||
| /* | ||
| * 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.patternedtext; | ||
|
|
||
| import org.elasticsearch.Build; | ||
| 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; | ||
| import static org.hamcrest.Matchers.not; | ||
|
|
||
| public class PatternedTextLicenseDowngradeIT extends DataStreamLicenseChangeTestCase { | ||
| @Before | ||
| public void checkClusterFeature() { | ||
| assumeTrue("[patterned_text] must be available", clusterHasFeature("mapper.patterned_text")); | ||
| assumeTrue("[patterned_text] is only available in snapshot builds", Build.current().isSnapshot()); | ||
| } | ||
|
|
||
| private static final String patternedTextMapping = """ | ||
| { | ||
| "template": { | ||
| "mappings": { | ||
| "properties": { | ||
| "patterned_field": { | ||
| "type": "patterned_text" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }"""; | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public void testLicenseDowngrade() throws IOException { | ||
| final String dataStreamName = "logs-test-patterned-text"; | ||
|
|
||
| startTrial(); | ||
| assertOK(putComponentTemplate(client(), "logs@custom", patternedTextMapping)); | ||
| assertOK(createDataStream(client(), dataStreamName)); | ||
|
|
||
| String backingIndex0 = getDataStreamBackingIndex(client(), dataStreamName, 0); | ||
| { | ||
| assertEquals("false", getSetting(client(), backingIndex0, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex0); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, not(hasKey("disable_templating"))); | ||
| } | ||
|
|
||
| startBasic(); | ||
| rolloverDataStream(client(), dataStreamName); | ||
|
|
||
| { | ||
| assertEquals("false", getSetting(client(), backingIndex0, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex0); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, not(hasKey("disable_templating"))); | ||
| } | ||
|
|
||
| String backingIndex1 = getDataStreamBackingIndex(client(), dataStreamName, 1); | ||
| { | ||
| assertEquals("true", getSetting(client(), backingIndex1, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex1); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, hasEntry("disable_templating", true)); | ||
| } | ||
|
|
||
| } | ||
| } |
81 changes: 81 additions & 0 deletions
81
...Test/java/org/elasticsearch/xpack/logsdb/patternedtext/PatternedTextLicenseUpgradeIT.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,81 @@ | ||
| /* | ||
| * 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.patternedtext; | ||
|
|
||
| import org.elasticsearch.Build; | ||
| 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; | ||
| import static org.hamcrest.Matchers.not; | ||
|
|
||
| public class PatternedTextLicenseUpgradeIT extends DataStreamLicenseChangeTestCase { | ||
| @Before | ||
| public void checkClusterFeature() { | ||
| assumeTrue("[patterned_text] must be available", clusterHasFeature("mapper.patterned_text")); | ||
| assumeTrue("[patterned_text] is only available in snapshot builds", Build.current().isSnapshot()); | ||
| } | ||
|
|
||
| private static final String patternedTextMapping = """ | ||
| { | ||
| "template": { | ||
| "mappings": { | ||
| "properties": { | ||
| "patterned_field": { | ||
| "type": "patterned_text" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }"""; | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public void testLicenseUpgrade() throws IOException { | ||
| final String dataStreamName = "logs-test-patterned-text"; | ||
|
|
||
| assertOK(putComponentTemplate(client(), "logs@custom", patternedTextMapping)); | ||
| assertOK(createDataStream(client(), dataStreamName)); | ||
|
|
||
| String backingIndex0 = getDataStreamBackingIndex(client(), dataStreamName, 0); | ||
| { | ||
| assertEquals("true", getSetting(client(), backingIndex0, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex0); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, hasEntry("disable_templating", true)); | ||
| } | ||
|
|
||
| startTrial(); | ||
| rolloverDataStream(client(), dataStreamName); | ||
|
|
||
| { | ||
| assertEquals("true", getSetting(client(), backingIndex0, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex0); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, hasEntry("disable_templating", true)); | ||
| } | ||
|
|
||
| String backingIndex1 = getDataStreamBackingIndex(client(), dataStreamName, 1); | ||
| { | ||
| assertEquals("false", getSetting(client(), backingIndex1, "index.mapping.patterned_text.disable_templating")); | ||
| Map<String, Object> mapping = getMapping(client(), backingIndex1); | ||
| Map<String, Object> patternedFieldMapping = (Map<String, Object>) ((Map<String, Object>) mapping.get("properties")).get( | ||
| "patterned_field" | ||
| ); | ||
| assertThat(patternedFieldMapping, not(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
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.