Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Avoid primary shard failure caused by merged segment warmer exceptions ([#19436](https://github.com/opensearch-project/OpenSearch/pull/19436))
- Fix pull-based ingestion out-of-bounds offset scenarios and remove persisted offsets ([#19607](https://github.com/opensearch-project/OpenSearch/pull/19607))
- [Star Tree] Fix sub-aggregator casting for search with profile=true ([19652](https://github.com/opensearch-project/OpenSearch/pull/19652))
- Remove default enable skip_list for @timestamp field or index sort field to fix upgrades ([19611](https://github.com/opensearch-project/OpenSearch/pull/19661))
- Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377))

### Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.common.util.LocaleUtils;
import org.opensearch.common.xcontent.support.XContentMapValues;
import org.opensearch.index.IndexSortConfig;
import org.opensearch.index.compositeindex.datacube.DimensionType;
import org.opensearch.index.fielddata.IndexFieldData;
import org.opensearch.index.fielddata.IndexNumericFieldData.NumericType;
Expand Down Expand Up @@ -754,7 +753,6 @@ public DocValueFormat docValueFormat(@Nullable String format, ZoneId timeZone) {
private final boolean indexed;
private final boolean hasDocValues;
private final boolean skiplist;
private final boolean isSkiplistConfigured;
private final Locale locale;
private final String format;
private final String printFormat;
Expand All @@ -780,7 +778,6 @@ private DateFieldMapper(
this.indexed = builder.index.getValue();
this.hasDocValues = builder.docValues.getValue();
this.skiplist = builder.skiplist.getValue();
this.isSkiplistConfigured = builder.skiplist.isConfigured();
this.locale = builder.locale.getValue();
this.format = builder.format.getValue();
this.printFormat = builder.printFormat.getValue();
Expand Down Expand Up @@ -838,7 +835,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
context.doc().add(new LongPoint(fieldType().name(), timestamp));
}
if (hasDocValues) {
if (skiplist || isSkiplistDefaultEnabled(context.indexSettings().getIndexSortConfig(), fieldType().name())) {
if (skiplist) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this result in same error if someone enables skiplist setting on a cluster having indices created with <= 2.19 version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we can leverage the dateFieldMapper.indexCreatedVersion property to validate the index version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, skip_list mapping is on creation only, so OS will reject the request to update the mapping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was repling to your 1st question.

I am wondering if we can leverage the dateFieldMapper.indexCreatedVersion property to validate the index version?

That should work for upgrade case. Let me confirm it manually, that'll be easy, then I can come up with bwc test case.

context.doc().add(SortedNumericDocValuesField.indexedField(fieldType().name(), timestamp));
} else {
context.doc().add(new SortedNumericDocValuesField(fieldType().name(), timestamp));
Expand All @@ -851,19 +848,6 @@ protected void parseCreateField(ParseContext context) throws IOException {
}
}

boolean isSkiplistDefaultEnabled(IndexSortConfig indexSortConfig, String fieldName) {
if (!isSkiplistConfigured) {
if (indexSortConfig.hasPrimarySortOnField(fieldName)) {
return true;
}
if (DataStreamFieldMapper.Defaults.TIMESTAMP_FIELD.getName().equals(fieldName)) {
return true;
}

}
return false;
}

@Override
protected String getFieldValue(ParseContext context) throws IOException {
if (context.externalValueSet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,10 @@
import org.apache.lucene.index.StoredFields;
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.opensearch.Version;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.time.DateFormatter;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.IndexSettings;
import org.opensearch.index.IndexSortConfig;
import org.opensearch.index.fieldvisitor.SingleFieldsVisitor;
import org.opensearch.index.termvectors.TermVectorsService;
import org.opensearch.search.DocValueFormat;
Expand Down Expand Up @@ -867,35 +862,6 @@ public void testSkipListIntegrationMappingDefinitionSerialization() throws IOExc
assertTrue("skip_list should be true in date_nanos mapper", dateFieldMapperNanos.skiplist());
}

public void testIsSkiplistDefaultEnabled() throws IOException {
DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "date")));
DateFieldMapper dateFieldMapper = (DateFieldMapper) mapper.mappers().getMapper("field");

// Test with no index sort and non-timestamp field
IndexMetadata noSortindexMetadata = new IndexMetadata.Builder("index").settings(getIndexSettings()).build();
IndexSettings noSolrIndexSettings = new IndexSettings(noSortindexMetadata, getIndexSettings());
IndexSortConfig noSortConfig = new IndexSortConfig(new IndexSettings(noSortindexMetadata, getIndexSettings()));
assertFalse(dateFieldMapper.isSkiplistDefaultEnabled(noSortConfig, "field"));

// timestamp field
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(noSortConfig, "@timestamp"));

// Create index settings with an index sort.
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.putList("index.sort.field", "field")
.build();

// Test with timestamp field
IndexMetadata indexMetadata = new IndexMetadata.Builder("index").settings(settings).build();
IndexSettings indexSettings = new IndexSettings(indexMetadata, settings);
IndexSortConfig sortConfig = new IndexSortConfig(indexSettings);
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "field"));
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "@timestamp"));
}

public void testSkipListIntegrationFieldBehaviorConsistency() throws IOException {
// Test that field behavior is consistent between skip_list enabled and disabled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@

public abstract class MapperServiceTestCase extends OpenSearchTestCase {

protected static final Settings SETTINGS = Settings.builder()
.put("index.version.created", Version.CURRENT)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.build();
protected static final Settings SETTINGS = Settings.builder().put("index.version.created", Version.CURRENT).build();

protected static final ToXContent.Params INCLUDE_DEFAULTS = new ToXContent.MapParams(
Collections.singletonMap("include_defaults", "true")
Expand Down
Loading