Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/135370.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 135370
summary: Add new `pattern_text` field mapper in tech preview
area: Mapping
type: feature
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public enum FeatureFlag {
SUB_OBJECTS_AUTO_ENABLED("es.sub_objects_auto_feature_flag_enabled=true", Version.fromString("8.16.0"), null),
DOC_VALUES_SKIPPER("es.doc_values_skipper_feature_flag_enabled=true", Version.fromString("8.18.1"), null),
LOGS_STREAM("es.logs_stream_feature_flag_enabled=true", Version.fromString("9.1.0"), null),
PATTERN_TEXT("es.pattern_text_feature_flag_enabled=true", Version.fromString("9.1.0"), null),
SYNTHETIC_VECTORS("es.mapping_synthetic_vectors=true", Version.fromString("9.2.0"), null),
INDEX_DIMENSIONS_TSID_OPTIMIZATION_FEATURE_FLAG(
"es.index_dimensions_tsid_optimization_feature_flag_enabled=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.FormatNames;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
Expand All @@ -39,7 +38,6 @@ public class PatternTextBasicRestIT extends ESRestTestCase {
.distribution(DistributionType.DEFAULT)
.setting("xpack.license.self_generated.type", "trial")
.setting("xpack.security.enabled", "false")
.feature(FeatureFlag.PATTERN_TEXT)
.build();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package org.elasticsearch.xpack.logsdb.patterntext;

import org.elasticsearch.Build;
import org.elasticsearch.xpack.logsdb.DataStreamLicenseChangeTestCase;
import org.junit.Before;

Expand All @@ -22,7 +21,6 @@ public class PatternTextLicenseDowngradeIT extends DataStreamLicenseChangeTestCa
@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 patternTextMapping = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package org.elasticsearch.xpack.logsdb.patterntext;

import org.elasticsearch.Build;
import org.elasticsearch.xpack.logsdb.DataStreamLicenseChangeTestCase;
import org.junit.Before;

Expand All @@ -22,7 +21,6 @@ public class PatternTextLicenseUpgradeIT 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 patternTextMapping = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

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

@Override
public List<Setting<?>> getSettings() {
List<Setting<?>> settings = new ArrayList<>(List.of(FALLBACK_SETTING, CLUSTER_LOGSDB_ENABLED, LOGSDB_PRIOR_LOGS_USAGE));
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
settings.add(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING);
}
return Collections.unmodifiableList(settings);
return List.of(
FALLBACK_SETTING,
CLUSTER_LOGSDB_ENABLED,
LOGSDB_PRIOR_LOGS_USAGE,
PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING
);
}

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

@Override
public Map<String, Mapper.TypeParser> getMappers() {
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
return singletonMap(PatternTextFieldType.CONTENT_TYPE, PatternTextFieldMapper.PARSER);
} else {
return Map.of();
}
return singletonMap(PatternTextFieldType.CONTENT_TYPE, PatternTextFieldMapper.PARSER);
}

protected XPackLicenseState getLicenseState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ && matchesLogsPattern(dataStreamName)) {
}
}

if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
&& licenseService.allowPatternTextTemplating(isTemplateValidation) == false) {
if (licenseService.allowPatternTextTemplating(isTemplateValidation) == false) {
additionalSettings.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.util.FeatureFlag;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.AnalyzerScope;
Expand Down Expand Up @@ -50,7 +49,6 @@
*/
public class PatternTextFieldMapper extends FieldMapper {

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,6 @@ public void testExplicitRoutingPathNotAllowedByLicense() throws Exception {
}

public void testPatternTextNotAllowedByLicense() throws Exception {
assumeTrue("pattern_text feature must be enabled", PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled());

MockLicenseState licenseState = MockLicenseState.createMock();
when(licenseState.copyCurrentLicenseState()).thenReturn(licenseState);
when(licenseState.isAllowed(same(LogsdbLicenseService.PATTERN_TEXT_TEMPLATING_FEATURE))).thenReturn(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public void testGetAdditionalIndexSettingsDefault() {
builder
);
var result = builder.build();
var expectedBuilder = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED");
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
expectedBuilder.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
}
assertEquals(expectedBuilder.build(), result);
var expected = Settings.builder()
.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED")
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
.build();
assertEquals(expected, result);
}

public void testGetAdditionalIndexSettingsApm() throws IOException {
Expand All @@ -101,17 +101,17 @@ public void testGetAdditionalIndexSettingsApm() throws IOException {
builder
);
var result = builder.build();
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
: Settings.EMPTY;
Settings expectedAdditionalSettings = Settings.builder()
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
.build();
assertEquals(expectedAdditionalSettings, result);
}

public void testGetAdditionalIndexSettingsProfiling() throws IOException {
Settings settings = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "SYNTHETIC").build();
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
: Settings.EMPTY;
Settings expectedAdditionalSettings = Settings.builder()
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
.build();
for (String dataStreamName : new String[] { "profiling-metrics", "profiling-events" }) {
String indexName = DataStream.getDefaultBackingIndexName(dataStreamName, 0);
Settings.Builder builder = Settings.builder();
Expand Down Expand Up @@ -155,9 +155,9 @@ public void testGetAdditionalIndexSettingsTsdb() throws IOException {
builder
);
var result = builder.build();
Settings expectedAdditionalSettings = PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()
? Settings.builder().put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true).build()
: Settings.EMPTY;
Settings expectedAdditionalSettings = Settings.builder()
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
.build();
assertEquals(expectedAdditionalSettings, result);
}

Expand Down Expand Up @@ -200,13 +200,12 @@ public void testGetAdditionalIndexSettingsTsdbAfterCutoffDate() throws Exception
IndexVersion.current(),
builder
);
var result = builder.build();

var expectedBuilder = Settings.builder().put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED");
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
expectedBuilder.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
}

assertEquals(expectedBuilder.build(), result);
var result = builder.build();
var expected = Settings.builder()
.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "STORED")
.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true)
.build();
assertEquals(expected, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.elasticsearch.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.logsdb.LogsDBPlugin;
import org.junit.AssumptionViolatedException;
import org.junit.Before;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -91,11 +90,6 @@ protected void assertExistsQuery(MappedFieldType fieldType, Query query, LuceneD
assertNoFieldNamesField(fields);
}

@Before
public void setup() {
assumeTrue("Only when pattern_text feature flag is enabled", PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled());
}

public void testExistsStandardSource() throws IOException {
assertExistsQuery(createMapperService(fieldMapping(b -> b.field("type", "pattern_text"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.logsdb.LogsDBPlugin;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;
import java.time.Instant;
Expand Down Expand Up @@ -110,16 +109,9 @@ protected Collection<Class<? extends Plugin>> getPlugins() {

private static final Settings LOGSDB_SETTING = Settings.builder().put(IndexSettings.MODE.getKey(), "logsdb").build();

@Before
public void setup() {
assumeTrue("Only when pattern_text feature flag is enabled", PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled());
}

@After
public void cleanup() {
if (PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled()) {
assertAcked(admin().indices().prepareDelete(INDEX));
}
assertAcked(admin().indices().prepareDelete(INDEX));
}

private String getMapping(String indexOptions, boolean disableTemplating) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.logsdb.LogsDBPlugin;
import org.junit.After;
import org.junit.Before;

import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -60,11 +59,6 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
.put(IndexSettings.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic")
.build();

@Before
public void setup() {
assumeTrue("Only when pattern_text feature flag is enabled", PatternTextFieldMapper.PATTERN_TEXT_MAPPER.isEnabled());
}

@After
public void cleanup() {
assertAcked(admin().indices().prepareDelete(INDEX).setIndicesOptions(IndicesOptions.lenientExpandOpen()).get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class LogsdbTestSuiteIT extends ESClientYamlSuiteTestCase {
.setting("xpack.security.autoconfiguration.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
.feature(FeatureFlag.DOC_VALUES_SKIPPER)
.feature(FeatureFlag.PATTERN_TEXT)
.build();

public LogsdbTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down