PointValues

abstract class 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

Basic point types in Java and Lucene
Java typeLucene 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:

  1. LatLonPoint: indexes (latitude,longitude) as (x,y) in two-dimensional space.

  2. {@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

Link copied to clipboard
object Companion
Link copied to clipboard

We recurse the PointTree, using a provided instance of this to guide the recursion.

Link copied to clipboard

Basic operations to read the KD-tree.

Link copied to clipboard

Used by .intersect to check how each recursive cell corresponds to the query.

Properties

Link copied to clipboard
abstract val bytesPerDimension: Int
Link copied to clipboard
abstract val docCount: Int

Returns the total number of documents that have indexed at least one point.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val numDimensions: Int
Link copied to clipboard
abstract val numIndexDimensions: Int
Link copied to clipboard

Functions

Link copied to clipboard

Estimate the number of documents that would be matched by .intersect with the given IntersectVisitor. This should run many times faster than .intersect.

Link copied to clipboard

Estimate the number of points that would be visited by .intersect with the given [ ]. This should run many times faster than .intersect.

Link copied to clipboard

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.

Link copied to clipboard
abstract fun size(): Long

Returns the total number of indexed points across all documents.