|
11 | 11 |
|
12 | 12 | import org.apache.lucene.search.Sort; |
13 | 13 | import org.apache.lucene.search.SortField; |
| 14 | +import org.apache.lucene.search.SortedNumericSelector; |
14 | 15 | import org.apache.lucene.search.SortedNumericSortField; |
15 | 16 | import org.apache.lucene.search.SortedSetSortField; |
16 | 17 | import org.elasticsearch.common.settings.Settings; |
@@ -80,6 +81,33 @@ public void testIndexSort() { |
80 | 81 | assertSortedSegments("test", indexSort); |
81 | 82 | } |
82 | 83 |
|
| 84 | + public void testIndexSortDateNanos() { |
| 85 | + prepareCreate("test").setSettings( |
| 86 | + Settings.builder() |
| 87 | + .put(indexSettings()) |
| 88 | + .put("index.number_of_shards", "1") |
| 89 | + .put("index.number_of_replicas", "1") |
| 90 | + .put("index.sort.field", "@timestamp") |
| 91 | + .put("index.sort.order", "desc") |
| 92 | + ).setMapping(""" |
| 93 | + { |
| 94 | + "properties": { |
| 95 | + "@timestamp": { |
| 96 | + "type": "date_nanos" |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | + """).get(); |
| 101 | + |
| 102 | + flushAndRefresh(); |
| 103 | + ensureYellow(); |
| 104 | + |
| 105 | + SortField sf = new SortedNumericSortField("@timestamp", SortField.Type.LONG, true, SortedNumericSelector.Type.MAX); |
| 106 | + sf.setMissingValue(0L); |
| 107 | + Sort expectedIndexSort = new Sort(sf); |
| 108 | + assertSortedSegments("test", expectedIndexSort); |
| 109 | + } |
| 110 | + |
83 | 111 | public void testInvalidIndexSort() { |
84 | 112 | IllegalArgumentException exc = expectThrows( |
85 | 113 | IllegalArgumentException.class, |
|
0 commit comments