Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.mapper.DateFieldMapper.DateFieldType;
import org.elasticsearch.inference.InferenceService;
import org.elasticsearch.search.lookup.SourceFilter;

Expand Down Expand Up @@ -530,19 +531,18 @@ public boolean isDataStreamTimestampFieldEnabled() {
}

/**
* 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
* skipper.
* @return {@code true} if contains a timestamp field of type date that has doc values and is either indexed or uses a doc values
* skipper, {@code false} otherwise.
* If this mapping contains a timestamp field that is of type date, has doc values, and is either indexed or uses a doc values
* skipper, this returns the field type for it.
*/
public boolean hasTimestampField() {
public DateFieldType getTimestampFieldType() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we mark the method as @Nullable so callers get some indication of the result needing a null check?

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, good point, I've pushed 14a7f67

final MappedFieldType mappedFieldType = fieldTypesLookup().get(DataStream.TIMESTAMP_FIELD_NAME);
if (mappedFieldType instanceof DateFieldMapper.DateFieldType dateMappedFieldType) {
if (mappedFieldType instanceof DateFieldType dateMappedFieldType) {
IndexType indexType = dateMappedFieldType.indexType();
return indexType.hasPoints() || indexType.hasDocValuesSkipper();
} else {
return false;
if (indexType.hasPoints() || indexType.hasDocValuesSkipper()) {
return dateMappedFieldType;
}
}
return null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,7 @@ private EngineConfig newEngineConfig(LongSupplier globalCheckpointSupplier) {
this.warmer.warm(reader);
}
};
final boolean isTimeBasedIndex = mapperService == null ? false : mapperService.mappingLookup().hasTimestampField();
final boolean isTimeBasedIndex = mapperService == null ? false : mapperService.mappingLookup().getTimestampFieldType() != null;
return new EngineConfig(
shardId,
threadPool,
Expand Down