Skip to content

Apache Lucene open-source search software

Cut over Lucene Demo from LongPoint to LongField. (#12052)

Adrien Grand56ec51e558c6
diff --git a/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java b/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java
index defadfb7d23..adcf824b52e 100644
--- a/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java
+++ b/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java
@@ -35,7 +35,7 @@ import org.apache.lucene.demo.knn.KnnVectorDict;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.KnnVectorField;
-import org.apache.lucene.document.LongPoint;
+import org.apache.lucene.document.LongField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
@@ -238,13 +238,14 @@ public class IndexFiles implements AutoCloseable {
doc.add(pathField);
// Add the last modified date of the file a field named "modified".
- // Use a LongPoint that is indexed (i.e. efficiently filterable with
- // PointRangeQuery). This indexes to milli-second resolution, which
+ // Use a LongField that is indexed with points and doc values, and is efficient
+ // for both filtering (LongField#newRangeQuery) and sorting
+ // (LongField#newSortField). This indexes to milli-second resolution, which
// is often too fine. You could instead create a number based on
// year/month/day/hour/minutes/seconds, down the resolution you require.
// For example the long value 2011021714 would mean
// February 17, 2011, 2-3 PM.
- doc.add(new LongPoint("modified", lastModified));
+ doc.add(new LongField("modified", lastModified));
// Add the contents of the file to a field named "contents". Specify a Reader,
// so that the text of the file is tokenized and indexed, but not stored.