|
8 | 8 | */ |
9 | 9 | package org.elasticsearch.index.mapper; |
10 | 10 |
|
| 11 | +import org.apache.lucene.document.Field; |
11 | 12 | import org.apache.lucene.document.LongPoint; |
12 | 13 | import org.apache.lucene.document.NumericDocValuesField; |
13 | 14 | import org.apache.lucene.document.SortedNumericDocValuesField; |
@@ -85,12 +86,51 @@ public void testIsFieldWithinQueryDateNanos() throws IOException { |
85 | 86 | isFieldWithinRangeTestCase(ft); |
86 | 87 | } |
87 | 88 |
|
| 89 | + public void testIsFieldWithinQueryDateMillisDocValueSkipper() throws IOException { |
| 90 | + DateFieldType ft = new DateFieldType( |
| 91 | + "my_date", |
| 92 | + false, |
| 93 | + false, |
| 94 | + false, |
| 95 | + true, |
| 96 | + true, |
| 97 | + DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, |
| 98 | + Resolution.MILLISECONDS, |
| 99 | + null, |
| 100 | + null, |
| 101 | + Collections.emptyMap() |
| 102 | + ); |
| 103 | + isFieldWithinRangeTestCase(ft); |
| 104 | + } |
| 105 | + |
| 106 | + public void testIsFieldWithinQueryDateNanosDocValueSkipper() throws IOException { |
| 107 | + DateFieldType ft = new DateFieldType( |
| 108 | + "my_date", |
| 109 | + false, |
| 110 | + false, |
| 111 | + false, |
| 112 | + true, |
| 113 | + true, |
| 114 | + DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER, |
| 115 | + Resolution.NANOSECONDS, |
| 116 | + null, |
| 117 | + null, |
| 118 | + Collections.emptyMap() |
| 119 | + ); |
| 120 | + isFieldWithinRangeTestCase(ft); |
| 121 | + } |
| 122 | + |
88 | 123 | public void isFieldWithinRangeTestCase(DateFieldType ft) throws IOException { |
89 | 124 |
|
90 | 125 | Directory dir = newDirectory(); |
91 | 126 | IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(null)); |
92 | 127 | LuceneDocument doc = new LuceneDocument(); |
93 | | - LongPoint field = new LongPoint("my_date", ft.parse("2015-10-12")); |
| 128 | + Field field; |
| 129 | + if (ft.hasDocValuesSkipper()) { |
| 130 | + field = SortedNumericDocValuesField.indexedField("my_date", ft.parse("2015-10-12")); |
| 131 | + } else { |
| 132 | + field = new LongPoint("my_date", ft.parse("2015-10-12")); |
| 133 | + } |
94 | 134 | doc.add(field); |
95 | 135 | w.addDocument(doc); |
96 | 136 | field.setLongValue(ft.parse("2016-04-03")); |
|
0 commit comments