Skip to content

Commit 675e175

Browse files
committed
DateFieldTypeTests#isFieldWithinRangeTestCase include doc values skipper
1 parent e7cee43 commit 675e175

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
package org.elasticsearch.index.mapper;
1010

11+
import org.apache.lucene.document.Field;
1112
import org.apache.lucene.document.LongPoint;
1213
import org.apache.lucene.document.NumericDocValuesField;
1314
import org.apache.lucene.document.SortedNumericDocValuesField;
@@ -85,12 +86,51 @@ public void testIsFieldWithinQueryDateNanos() throws IOException {
8586
isFieldWithinRangeTestCase(ft);
8687
}
8788

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+
88123
public void isFieldWithinRangeTestCase(DateFieldType ft) throws IOException {
89124

90125
Directory dir = newDirectory();
91126
IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(null));
92127
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+
}
94134
doc.add(field);
95135
w.addDocument(doc);
96136
field.setLongValue(ft.parse("2016-04-03"));

0 commit comments

Comments
 (0)