|
15 | 15 | import org.apache.lucene.index.PointValues; |
16 | 16 | import org.apache.lucene.index.Terms; |
17 | 17 | import org.apache.lucene.search.FieldComparator; |
18 | | -import org.apache.lucene.search.FieldComparatorSource; |
19 | 18 | import org.apache.lucene.search.Pruning; |
20 | 19 | import org.apache.lucene.search.SortField; |
21 | 20 | import org.elasticsearch.ElasticsearchParseException; |
|
27 | 26 | import org.elasticsearch.common.time.DateMathParser; |
28 | 27 | import org.elasticsearch.common.time.DateUtils; |
29 | 28 | import org.elasticsearch.common.util.BigArrays; |
| 29 | +import org.elasticsearch.index.IndexMode; |
30 | 30 | import org.elasticsearch.index.IndexSortConfig; |
31 | 31 | import org.elasticsearch.index.fielddata.IndexFieldData; |
32 | 32 | import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; |
@@ -379,12 +379,30 @@ public SortFieldAndFormat build(SearchExecutionContext context) throws IOExcepti |
379 | 379 | // TODO: HACK to wire up the special timestamp comparator |
380 | 380 | // (typically we default to Lucene's sort fields and enabling a custom sort field for timestamp field mapper fails, |
381 | 381 | // because index sorting uses this as well. Index sorting doesn't support custom sort fields. Need to fix this) |
382 | | - if (DataStream.TIMESTAMP_FIELD_NAME.equals(fieldName)) { |
383 | | - field = new SortField(getFieldName(), new FieldComparatorSource() { |
| 382 | + var indexMode = context.getIndexSettings().getMode(); |
| 383 | + if (DataStream.TIMESTAMP_FIELD_NAME.equals(fieldName) |
| 384 | + && (indexMode == IndexMode.LOGSDB || indexMode == IndexMode.TIME_SERIES)) { |
| 385 | + field = new SortField(getFieldName(), new IndexFieldData.XFieldComparatorSource(missing, localSortMode(), nested) { |
384 | 386 | @Override |
385 | 387 | public FieldComparator<?> newComparator(String fieldname, int numHits, Pruning pruning, boolean reversed) { |
386 | 388 | return new TimestampComparator(numHits, reversed); |
387 | 389 | } |
| 390 | + |
| 391 | + @Override |
| 392 | + public SortField.Type reducedType() { |
| 393 | + return SortField.Type.LONG; |
| 394 | + } |
| 395 | + |
| 396 | + @Override |
| 397 | + public BucketedSort newBucketedSort( |
| 398 | + BigArrays bigArrays, |
| 399 | + SortOrder sortOrder, |
| 400 | + DocValueFormat format, |
| 401 | + int bucketSize, |
| 402 | + BucketedSort.ExtraData extra |
| 403 | + ) { |
| 404 | + throw new UnsupportedOperationException("not yet implemented"); |
| 405 | + } |
388 | 406 | }, reverse); |
389 | 407 | } else { |
390 | 408 | field = fieldData.sortField(missing, localSortMode(), nested, reverse); |
|
0 commit comments