Skip to content

Commit d3ad4e6

Browse files
committed
Update DateFieldMapper#shouldUseDocValuesSkipper to support TSDB
1 parent e251d86 commit d3ad4e6

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

server/src/main/java/org/elasticsearch/index/IndexVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private static Version parseUnchecked(String version) {
150150
public static final IndexVersion TIMESTAMP_DOC_VALUES_SPARSE_INDEX = def(9_011_0_00, Version.LUCENE_10_1_0);
151151
public static final IndexVersion TIME_SERIES_ID_DOC_VALUES_SPARSE_INDEX = def(9_012_0_00, Version.LUCENE_10_1_0);
152152
public static final IndexVersion SYNTHETIC_SOURCE_STORE_ARRAYS_NATIVELY_KEYWORD = def(9_013_0_00, Version.LUCENE_10_1_0);
153+
public static final IndexVersion TSDB_TIMESTAMP_DOC_VALUES_SPARSE_INDEX = def(9_014_0_00, Version.LUCENE_10_1_0);
153154
/*
154155
* STOP! READ THIS FIRST! No, really,
155156
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,10 @@ private DateFieldMapper(
10301030
* Determines whether the doc values skipper (sparse index) should be used for the {@code @timestamp} field.
10311031
* <p>
10321032
* The doc values skipper is enabled only if {@code index.mapping.use_doc_values_skipper} is set to {@code true},
1033-
* the index was created on or after {@link IndexVersions#TIMESTAMP_DOC_VALUES_SPARSE_INDEX}, and the
1034-
* field has doc values enabled. Additionally, the index mode must be {@link IndexMode#LOGSDB}, and
1035-
* the index sorting configuration must include the {@code @timestamp} field.
1033+
* the index was created on or after {@link IndexVersions#TIMESTAMP_DOC_VALUES_SPARSE_INDEX}
1034+
* ({@link IndexVersions#TSDB_TIMESTAMP_DOC_VALUES_SPARSE_INDEX} for time-series indices), and the
1035+
* field has doc values enabled. Additionally, the index mode must be {@link IndexMode#LOGSDB} or {@link IndexMode#TIME_SERIES}, and for
1036+
* logsdb indices the index sorting configuration must include the {@code @timestamp} field.
10361037
*
10371038
* @param indexCreatedVersion The version of the index when it was created.
10381039
* @param useDocValuesSkipper Whether the doc values skipper feature is enabled via the {@code index.mapping.use_doc_values_skipper}
@@ -1052,13 +1053,21 @@ private static boolean shouldUseDocValuesSkipper(
10521053
final IndexSortConfig indexSortConfig,
10531054
final String fullFieldName
10541055
) {
1055-
return indexCreatedVersion.onOrAfter(IndexVersions.TIMESTAMP_DOC_VALUES_SPARSE_INDEX)
1056-
&& useDocValuesSkipper
1057-
&& hasDocValues
1058-
&& IndexMode.LOGSDB.equals(indexMode)
1059-
&& indexSortConfig != null
1060-
&& indexSortConfig.hasSortOnField(fullFieldName)
1061-
&& DataStreamTimestampFieldMapper.DEFAULT_PATH.equals(fullFieldName);
1056+
if (IndexMode.LOGSDB.equals(indexMode)) {
1057+
return indexCreatedVersion.onOrAfter(IndexVersions.TIMESTAMP_DOC_VALUES_SPARSE_INDEX)
1058+
&& useDocValuesSkipper
1059+
&& hasDocValues
1060+
&& indexSortConfig != null
1061+
&& indexSortConfig.hasSortOnField(fullFieldName)
1062+
&& DataStreamTimestampFieldMapper.DEFAULT_PATH.equals(fullFieldName);
1063+
} else if (IndexMode.TIME_SERIES.equals(indexMode)) {
1064+
return indexCreatedVersion.onOrAfter(IndexVersions.TSDB_TIMESTAMP_DOC_VALUES_SPARSE_INDEX)
1065+
&& useDocValuesSkipper
1066+
&& hasDocValues
1067+
&& DataStreamTimestampFieldMapper.DEFAULT_PATH.equals(fullFieldName);
1068+
} else {
1069+
return false;
1070+
}
10621071
}
10631072

10641073
@Override

0 commit comments

Comments
 (0)