Skip to content

Commit e426757

Browse files
Remove pattern_text feature flag (#135370)
This PR removes the feature flag from the new pattern_text mapper, making it available in tech preview. This minimal version of patterned text mapping uses simple parsing to decompose log message into template and arguments doc values, with a single inverted index built from the original message. Relates to #128931
1 parent 1d7be3f commit e426757

File tree

14 files changed

+34
-67
lines changed

14 files changed

+34
-67
lines changed

docs/changelog/135370.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135370
2+
summary: Add new `pattern_text` field mapper in tech preview
3+
area: Mapping
4+
type: feature
5+
issues: []

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public enum FeatureFlag {
2020
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
2121
DOC_VALUES_SKIPPER("es.doc_values_skipper_feature_flag_enabled=true", Version.fromString("8.18.1"), null),
2222
LOGS_STREAM("es.logs_stream_feature_flag_enabled=true", Version.fromString("9.1.0"), null),
23-
PATTERN_TEXT("es.pattern_text_feature_flag_enabled=true", Version.fromString("9.1.0"), null),
2423
SYNTHETIC_VECTORS("es.mapping_synthetic_vectors=true", Version.fromString("9.2.0"), null),
2524
INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG(
2625
"es.index_dimensions_tsid_optimization_feature_flag_enabled=true",

x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/patterntext/PatternTextBasicRestIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.common.time.DateFormatter;
1616
import org.elasticsearch.common.time.FormatNames;
1717
import org.elasticsearch.test.cluster.ElasticsearchCluster;
18-
import org.elasticsearch.test.cluster.FeatureFlag;
1918
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
2019
import org.elasticsearch.test.rest.ESRestTestCase;
2120
import org.elasticsearch.test.rest.ObjectPath;
@@ -39,7 +38,6 @@ public class PatternTextBasicRestIT extends ESRestTestCase {
3938
.distribution(DistributionType.DEFAULT)
4039
.setting("xpack.license.self_generated.type", "trial")
4140
.setting("xpack.security.enabled", "false")
42-
.feature(FeatureFlag.PATTERN_TEXT)
4341
.build();
4442

4543
@Override

x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/patterntext/PatternTextLicenseDowngradeIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.logsdb.patterntext;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.xpack.logsdb.DataStreamLicenseChangeTestCase;
1211
import org.junit.Before;
1312

@@ -22,7 +21,6 @@ public class PatternTextLicenseDowngradeIT extends DataStreamLicenseChangeTestCa
2221
@Before
2322
public void checkClusterFeature() {
2423
assumeTrue("[patterned_text] must be available", clusterHasFeature("mapper.patterned_text"));
25-
assumeTrue("[patterned_text] is only available in snapshot builds", Build.current().isSnapshot());
2624
}
2725

2826
private static final String patternTextMapping = """

x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/patterntext/PatternTextLicenseUpgradeIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.logsdb.patterntext;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.xpack.logsdb.DataStreamLicenseChangeTestCase;
1211
import org.junit.Before;
1312

@@ -22,7 +21,6 @@ public class PatternTextLicenseUpgradeIT extends DataStreamLicenseChangeTestCase
2221
@Before
2322
public void checkClusterFeature() {
2423
assumeTrue("[patterned_text] must be available", clusterHasFeature("mapper.patterned_text"));
25-
assumeTrue("[patterned_text] is only available in snapshot builds", Build.current().isSnapshot());
2624
}
2725

2826
private static final String patternTextMapping = """

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBPlugin.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import java.util.ArrayList;
2828
import java.util.Collection;
29-
import java.util.Collections;
3029
import java.util.List;
3130
import java.util.Map;
3231

@@ -94,11 +93,12 @@ public Collection<IndexSettingProvider> getAdditionalIndexSettingProviders(Index
9493

9594
@Override
9695
public List<Setting<?>> getSettings() {
97-
List<Setting<?>> settings = new ArrayList<>(List.of(FALLBACK_SETTING, CLUSTER_LOGSDB_ENABLED, LOGSDB_PRIOR_LOGS_USAGE));
98-
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
99-
settings.add(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING);
100-
}
101-
return Collections.unmodifiableList(settings);
96+
return List.of(
97+
FALLBACK_SETTING,
98+
CLUSTER_LOGSDB_ENABLED,
99+
LOGSDB_PRIOR_LOGS_USAGE,
100+
PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING
101+
);
102102
}
103103

104104
@Override
@@ -111,11 +111,7 @@ public List<ActionPlugin.ActionHandler> getActions() {
111111

112112
@Override
113113
public Map<String, Mapper.TypeParser> getMappers() {
114-
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
115-
return singletonMap(PatternTextFieldType.CONTENT_TYPE, PatternTextFieldMapper.PARSER);
116-
} else {
117-
return Map.of();
118-
}
114+
return singletonMap(PatternTextFieldType.CONTENT_TYPE, PatternTextFieldMapper.PARSER);
119115
}
120116

121117
protected XPackLicenseState getLicenseState() {

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsdbIndexModeSettingsProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ && matchesLogsPattern(dataStreamName)) {
192192
}
193193
}
194194

195-
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
196-
&& licenseService.allowPatternTextTemplating(isTemplateValidation) == false) {
195+
if (licenseService.allowPatternTextTemplating(isTemplateValidation) == false) {
197196
additionalSettings.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
198197
}
199198
}

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/patterntext/PatternTextFieldMapper.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.apache.lucene.index.LeafReader;
1818
import org.apache.lucene.util.BytesRef;
1919
import org.elasticsearch.common.settings.Setting;
20-
import org.elasticsearch.common.util.FeatureFlag;
2120
import org.elasticsearch.index.IndexSettings;
2221
import org.elasticsearch.index.IndexVersion;
2322
import org.elasticsearch.index.analysis.AnalyzerScope;
@@ -50,7 +49,6 @@
5049
*/
5150
public class PatternTextFieldMapper extends FieldMapper {
5251

53-
public static final FeatureFlag PATTERN_TEXT_MAPPER = new FeatureFlag("pattern_text");
5452
private static final NamedAnalyzer STANDARD_ANALYZER = new NamedAnalyzer("standard", AnalyzerScope.GLOBAL, new StandardAnalyzer());
5553

5654
/**

x-pack/plugin/logsdb/src/test/java/org/elasticsearch/xpack/logsdb/LogsdbIndexModeSettingsProviderTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,6 @@ public void testExplicitRoutingPathNotAllowedByLicense() throws Exception {
960960
}
961961

962962
public void testPatternTextNotAllowedByLicense() throws Exception {
963-
assumeTrue("pattern_text feature must be enabled", PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled());
964-
965963
MockLicenseState licenseState = MockLicenseState.createMock();
966964
when(licenseState.copyCurrentLicenseState()).thenReturn(licenseState);
967965
when(licenseState.isAllowed(same(LogsdbLicenseService.PATTERN_TEXT_TEMPLATING_FEATURE))).thenReturn(false);

x-pack/plugin/logsdb/src/test/java/org/elasticsearch/xpack/logsdb/LogsdbIndexSettingsProviderLegacyLicenseTests.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ public void testGetAdditionalIndexSettingsDefault() {
7777
builder
7878
);
7979
var result = builder.build();
80-
var expectedBuilder = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED");
81-
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
82-
expectedBuilder.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
83-
}
84-
assertEquals(expectedBuilder.build(), result);
80+
var expected = Settings.builder()
81+
.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED")
82+
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
83+
.build();
84+
assertEquals(expected, result);
8585
}
8686

8787
public void testGetAdditionalIndexSettingsApm() throws IOException {
@@ -101,17 +101,17 @@ public void testGetAdditionalIndexSettingsApm() throws IOException {
101101
builder
102102
);
103103
var result = builder.build();
104-
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
105-
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
106-
: Settings.EMPTY;
104+
Settings expectedAdditionalSettings = Settings.builder()
105+
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
106+
.build();
107107
assertEquals(expectedAdditionalSettings, result);
108108
}
109109

110110
public void testGetAdditionalIndexSettingsProfiling() throws IOException {
111111
Settings settings = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "SYNTHETIC").build();
112-
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
113-
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
114-
: Settings.EMPTY;
112+
Settings expectedAdditionalSettings = Settings.builder()
113+
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
114+
.build();
115115
for (String dataStreamName : new String[] { "profiling-metrics", "profiling-events" }) {
116116
String indexName = DataStream.getDefaultBackingIndexName(dataStreamName, 0);
117117
Settings.Builder builder = Settings.builder();
@@ -155,9 +155,9 @@ public void testGetAdditionalIndexSettingsTsdb() throws IOException {
155155
builder
156156
);
157157
var result = builder.build();
158-
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
159-
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
160-
: Settings.EMPTY;
158+
Settings expectedAdditionalSettings = Settings.builder()
159+
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
160+
.build();
161161
assertEquals(expectedAdditionalSettings, result);
162162
}
163163

@@ -200,13 +200,12 @@ public void testGetAdditionalIndexSettingsTsdbAfterCutoffDate() throws Exception
200200
IndexVersion.current(),
201201
builder
202202
);
203-
var result = builder.build();
204203

205-
var expectedBuilder = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED");
206-
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
207-
expectedBuilder.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
208-
}
209-
210-
assertEquals(expectedBuilder.build(), result);
204+
var result = builder.build();
205+
var expected = Settings.builder()
206+
.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED")
207+
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
208+
.build();
209+
assertEquals(expected, result);
211210
}
212211
}

0 commit comments

Comments
 (0)