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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add all-active ingestion as docrep equivalent in pull-based ingestion ([#19316](https://github.com/opensearch-project/OpenSearch/pull/19316))
- Adding logic for histogram aggregation using skiplist ([#19130](https://github.com/opensearch-project/OpenSearch/pull/19130))
- Add skip_list param for date, scaled float and token count fields ([#19142](https://github.com/opensearch-project/OpenSearch/pull/19142))
- Enable skip_list for @timestamp field or index sort field by default([#19480](https://github.com/opensearch-project/OpenSearch/pull/19480))
- Implement GRPC MatchPhrase, MultiMatch queries ([#19449](https://github.com/opensearch-project/OpenSearch/pull/19449))
- Optimize gRPC transport thread management for improved throughput ([#19278](https://github.com/opensearch-project/OpenSearch/pull/19278))
- Implement GRPC Boolean query and inject registry for all internal query converters ([#19391](https://github.com/opensearch-project/OpenSearch/pull/19391))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
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 @@ -753,6 +754,7 @@ 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 @@ -778,6 +780,7 @@ 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 @@ -846,7 +849,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
context.doc().add(new LongPoint(fieldType().name(), timestamp));
}
if (hasDocValues) {
if (skiplist) {
if (skiplist || isSkiplistDefaultEnabled(context.indexSettings().getIndexSortConfig(), fieldType().name())) {
context.doc().add(SortedNumericDocValuesField.indexedField(fieldType().name(), timestamp));
} else {
context.doc().add(new SortedNumericDocValuesField(fieldType().name(), timestamp));
Expand All @@ -859,6 +862,19 @@ 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;
}

public Long getNullValue() {
return nullValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@
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 @@ -833,6 +838,35 @@ 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,7 +80,11 @@

public abstract class MapperServiceTestCase extends OpenSearchTestCase {

protected static final Settings SETTINGS = Settings.builder().put("index.version.created", Version.CURRENT).build();
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 ToXContent.Params INCLUDE_DEFAULTS = new ToXContent.MapParams(
Collections.singletonMap("include_defaults", "true")
Expand Down
Loading