Skip to content

Commit 6296cb4

Browse files
opensearch-trigger-bot[bot]github-actions[bot]sandeshkr419peterzhuamazon
authored andcommitted
[Forwardport main] Fix @timestamp upgrade issue by adding a version check on skip_list param (opensearch-project#19677)
* Fix @timestamp upgrade issue by adding a version check on skip_list param (bwc) (opensearch-project#19671) Fixes opensearch-project#19660 Signed-off-by: Asim Mahmood <asim.seng@gmail.com> Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com> Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com> (cherry picked from commit 0b6a2c9) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Removed changelog of items part of 3.3.1 Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com> --------- Signed-off-by: Asim Mahmood <asim.seng@gmail.com> Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com> Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent 24aecf3 commit 6296cb4

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3030
- Fix flaky test FieldDataLoadingIT.testIndicesFieldDataCacheSizeSetting ([#19571](https://github.com/opensearch-project/OpenSearch/pull/19571))
3131
- Avoid primary shard failure caused by merged segment warmer exceptions ([#19436](https://github.com/opensearch-project/OpenSearch/pull/19436))
3232
- Fix pull-based ingestion out-of-bounds offset scenarios and remove persisted offsets ([#19607](https://github.com/opensearch-project/OpenSearch/pull/19607))
33-
- [Star Tree] Fix sub-aggregator casting for search with profile=true ([19652](https://github.com/opensearch-project/OpenSearch/pull/19652))
3433
- Fix issue with updating core with a patch number other than 0 ([#19377](https://github.com/opensearch-project/OpenSearch/pull/19377))
3534
- [Java Agent] Allow JRT protocol URLs in protection domain extraction ([#19683](https://github.com/opensearch-project/OpenSearch/pull/19683))
3635

server/src/main/java/org/opensearch/index/mapper/DateFieldMapper.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,14 +852,15 @@ protected void parseCreateField(ParseContext context) throws IOException {
852852
}
853853

854854
boolean isSkiplistDefaultEnabled(IndexSortConfig indexSortConfig, String fieldName) {
855-
if (!isSkiplistConfigured) {
856-
if (indexSortConfig.hasPrimarySortOnField(fieldName)) {
857-
return true;
858-
}
859-
if (DataStreamFieldMapper.Defaults.TIMESTAMP_FIELD.getName().equals(fieldName)) {
860-
return true;
855+
if (this.indexCreatedVersion.onOrAfter(Version.V_3_3_0)) {
856+
if (!isSkiplistConfigured) {
857+
if (indexSortConfig.hasPrimarySortOnField(fieldName)) {
858+
return true;
859+
}
860+
if (DataStreamFieldMapper.Defaults.TIMESTAMP_FIELD.getName().equals(fieldName)) {
861+
return true;
862+
}
861863
}
862-
863864
}
864865
return false;
865866
}

server/src/test/java/org/opensearch/index/mapper/DateFieldMapperTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,16 +869,25 @@ public void testSkipListIntegrationMappingDefinitionSerialization() throws IOExc
869869

870870
public void testIsSkiplistDefaultEnabled() throws IOException {
871871
DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "date")));
872+
testIsSkiplistEnabled(mapper, true);
873+
874+
}
875+
876+
public void testIsSkiplistDefaultDisabledInOlderVersions() throws IOException {
877+
DocumentMapper mapper = createDocumentMapper(Version.V_3_2_0, fieldMapping(b -> b.field("type", "date")));
878+
testIsSkiplistEnabled(mapper, false);
879+
}
880+
881+
private void testIsSkiplistEnabled(DocumentMapper mapper, boolean expectedValue) throws IOException {
872882
DateFieldMapper dateFieldMapper = (DateFieldMapper) mapper.mappers().getMapper("field");
873883

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

880889
// timestamp field
881-
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(noSortConfig, "@timestamp"));
890+
assertEquals(expectedValue, dateFieldMapper.isSkiplistDefaultEnabled(noSortConfig, "@timestamp"));
882891

883892
// Create index settings with an index sort.
884893
Settings settings = Settings.builder()
@@ -892,8 +901,8 @@ public void testIsSkiplistDefaultEnabled() throws IOException {
892901
IndexMetadata indexMetadata = new IndexMetadata.Builder("index").settings(settings).build();
893902
IndexSettings indexSettings = new IndexSettings(indexMetadata, settings);
894903
IndexSortConfig sortConfig = new IndexSortConfig(indexSettings);
895-
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "field"));
896-
assertTrue(dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "@timestamp"));
904+
assertEquals(expectedValue, dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "field"));
905+
assertEquals(expectedValue, dateFieldMapper.isSkiplistDefaultEnabled(sortConfig, "@timestamp"));
897906
}
898907

899908
public void testSkipListIntegrationFieldBehaviorConsistency() throws IOException {

0 commit comments

Comments
 (0)