You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2023/01/11 09:03:11 UTC

[lucene] 01/02: Cut over Lucene Demo from LongPoint to LongField. (#12052)

This is an automated email from the ASF dual-hosted git repository.

jpountz pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 87d8ab9ca282ddebf88546bf29e653302846a0e2
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Wed Jan 11 09:43:43 2023 +0100

    Cut over Lucene Demo from LongPoint to LongField. (#12052)
---
 lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

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.