Lucene's LongPoint Data Type
Overview
The LongPoint
data type in Lucene is a specialized field designed for storing and querying long integer values, typically used for numeric range queries.
Key Features
1. Purpose
- What: Used for range queries.
- Why: Enables efficient performance of range searches, for instance, to find all documents with a last modified time within a specific range.
2. Storage
3. Usage
- What: Not stored in human-readable format.
- Why: Optimized for quick and efficient searching.
- What: Ideal for filtering or searching based on a range of long integer values.
- Example: Querying documents that have a last modified time between
1612137600
and1614825600
.
Code Example
Here's a code snippet to demonstrate how LongPoint
is added to a Lucene Document.
import org.apache.lucene.document.Document;
import org.apache.lucene.document.LongPoint;
Document doc = new Document();
long lastModifiedTime = 1612137600L; // Example timestamp
doc.add(new LongPoint("lastModified", lastModifiedTime));
Notes
To store actual value also use Lucene's StoredField Data Type
Backlinks