PointValues
Access to indexed numeric values.
Points represent numeric values and are indexed differently than ordinary text. Instead of an inverted index, points are indexed with datastructures such as KD-trees. These structures are optimized for operations such as range, distance, nearest-neighbor, and point-in-polygon queries.
Basic Point Types
| Java type | Lucene class |
|---|---|
| `int` | [IntPoint] |
| `long` | [LongPoint] |
| `float` | [FloatPoint] |
| `double` | [DoublePoint] |
| `byte[]` | [BinaryPoint] |
| [InetAddress] | [InetAddressPoint] |
| [BigInteger] | [BigIntegerPoint]({@docRoot}/../sandbox/org/apache/lucene/sandbox/document/BigIntegerPoint.html)* |
in the lucene-sandbox jar
Basic Lucene point types behave like their java peers: for example IntPoint represents a signed 32-bit Integer, supporting values ranging from Integer.MIN_VALUE to Integer.MAX_VALUE, ordered consistent with Integer.compareTo. In addition to indexing support, point classes also contain static methods (such as IntPoint.newRangeQuery) for creating common queries. For example:
// add year 1970 to document
document.add(new IntPoint("year", 1970));
// index document
writer.addDocument(document);
...
// issue range query of 1960-1980
Query query = IntPoint.newRangeQuery("year", 1960, 1980);
TopDocs docs = searcher.search(query, ...);
*Geospatial Point Types
Although basic point types such as DoublePoint support points in multi-dimensional space too, Lucene has specialized classes for location data. These classes are optimized for location data: they are more space-efficient and support special operations such as distance and polygon queries. There are currently two implementations:
LatLonPoint: indexes
(latitude,longitude)as(x,y)in two-dimensional space.{@docRoot}/../spatial3d/org/apache/lucene/spatial3d/Geo3DPoint.html* in lucene-spatial3d: indexes
(latitude,longitude)as(x,y,z)in three-dimensional space.
does not support altitude, 3D here means "uses three dimensions under-the-hood"
Advanced usage
Custom structures can be created on top of single- or multi- dimensional basic types, on top of BinaryPoint for more flexibility, or via custom Field subclasses.
Inheritors
Types
We recurse the PointTree, using a provided instance of this to guide the recursion.
Basic operations to read the KD-tree.
Used by .intersect to check how each recursive cell corresponds to the query.
Properties
Functions
Estimate the number of documents that would be matched by .intersect with the given IntersectVisitor. This should run many times faster than .intersect.
Estimate the number of points that would be visited by .intersect with the given [ ]. This should run many times faster than .intersect.
Finds all documents and points matching the provided visitor. This method does not enforce live documents, so it's up to the caller to test whether each document is deleted, if necessary.