Skip to content

Commit 7027710

Browse files
Expose field mapper type for timestamp field
1 parent 490a2d5 commit 7027710

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.index.IndexSettings;
1616
import org.elasticsearch.index.analysis.IndexAnalyzers;
1717
import org.elasticsearch.index.analysis.NamedAnalyzer;
18+
import org.elasticsearch.index.mapper.DateFieldMapper.DateFieldType;
1819
import org.elasticsearch.inference.InferenceService;
1920
import org.elasticsearch.search.lookup.SourceFilter;
2021

@@ -530,19 +531,18 @@ public boolean isDataStreamTimestampFieldEnabled() {
530531
}
531532

532533
/**
533-
* Returns if this mapping contains a timestamp field that is of type date, has doc values, and is either indexed or uses a doc values
534-
* skipper.
535-
* @return {@code true} if contains a timestamp field of type date that has doc values and is either indexed or uses a doc values
536-
* skipper, {@code false} otherwise.
534+
* If this mapping contains a timestamp field that is of type date, has doc values, and is either indexed or uses a doc values
535+
* skipper, this returns the field type for it.
537536
*/
538-
public boolean hasTimestampField() {
537+
public DateFieldType getTimestampFieldType() {
539538
final MappedFieldType mappedFieldType = fieldTypesLookup().get(DataStream.TIMESTAMP_FIELD_NAME);
540-
if (mappedFieldType instanceof DateFieldMapper.DateFieldType dateMappedFieldType) {
539+
if (mappedFieldType instanceof DateFieldType dateMappedFieldType) {
541540
IndexType indexType = dateMappedFieldType.indexType();
542-
return indexType.hasPoints() || indexType.hasDocValuesSkipper();
543-
} else {
544-
return false;
541+
if (indexType.hasPoints() || indexType.hasDocValuesSkipper()) {
542+
return dateMappedFieldType;
543+
}
545544
}
545+
return null;
546546
}
547547

548548
/**

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3842,7 +3842,7 @@ private EngineConfig newEngineConfig(LongSupplier globalCheckpointSupplier) {
38423842
this.warmer.warm(reader);
38433843
}
38443844
};
3845-
final boolean isTimeBasedIndex = mapperService == null ? false : mapperService.mappingLookup().hasTimestampField();
3845+
final boolean isTimeBasedIndex = mapperService == null ? false : mapperService.mappingLookup().getTimestampFieldType() != null;
38463846
return new EngineConfig(
38473847
shardId,
38483848
threadPool,

0 commit comments

Comments
 (0)