Skip to content

Commit 3e0e535

Browse files
committed
iter2
1 parent 314762f commit 3e0e535

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

server/src/main/java/org/elasticsearch/lucene/queries/TimestampComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class TimestampLeafComparator implements LeafFieldComparator {
108108
primaryFieldSkipper = null;
109109
}
110110

111-
if (timestampSkipper.maxValue() < bottom) {
111+
if (timestampSkipper == null || timestampSkipper.maxValue() < bottom) {
112112
this.competitiveIterator = DocIdSetIterator.empty();
113113
} else {
114114
this.competitiveIterator = DocIdSetIterator.all(maxDoc);

server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ public SortFieldAndFormat build(SearchExecutionContext context) throws IOExcepti
380380
// (typically we default to Lucene's sort fields and enabling a custom sort field for timestamp field mapper fails,
381381
// because index sorting uses this as well. Index sorting doesn't support custom sort fields. Need to fix this)
382382
var indexMode = context.getIndexSettings().getMode();
383+
boolean sortOnTimestamp = context.getIndexSettings().getIndexSortConfig().hasSortOnField(DataStream.TIMESTAMP_FIELD_NAME);
383384
if (DataStream.TIMESTAMP_FIELD_NAME.equals(fieldName)
385+
&& sortOnTimestamp
384386
&& (indexMode == IndexMode.LOGSDB || indexMode == IndexMode.TIME_SERIES)) {
385387
field = new SortField(getFieldName(), new IndexFieldData.XFieldComparatorSource(missing, localSortMode(), nested) {
386388
@Override

0 commit comments

Comments
 (0)