public abstract class PointValues extends Object
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.
Java type | Lucene class |
---|---|
int | IntPoint |
long | LongPoint |
float | FloatPoint |
double | DoublePoint |
byte[] | BinaryPoint |
BigInteger | BigIntegerPoint* |
InetAddress | InetAddressPoint* |
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(Integer)
. In addition to indexing support, point classes also contain
static methods (such as IntPoint.newRangeQuery(String, int, int)
) 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, ...);
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:
(latitude,longitude)
as (x,y)
in two-dimensional space.
(latitude,longitude)
as (x,y,z)
in three-dimensional space.
BinaryPoint
for more flexibility, or via custom Field
subclasses.Modifier and Type | Class and Description |
---|---|
static interface |
PointValues.IntersectVisitor
We recurse the BKD tree, using a provided instance of this to guide the recursion.
|
static class |
PointValues.Relation
Used by
intersect(java.lang.String, org.apache.lucene.index.PointValues.IntersectVisitor) to check how each recursive cell corresponds to the query. |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_DIMENSIONS
Maximum number of dimensions
|
static int |
MAX_NUM_BYTES
Maximum number of bytes for each dimension
|
Modifier | Constructor and Description |
---|---|
protected |
PointValues()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
abstract long |
estimatePointCount(String fieldName,
PointValues.IntersectVisitor visitor)
Estimate the number of points that would be visited by
intersect(java.lang.String, org.apache.lucene.index.PointValues.IntersectVisitor)
with the given PointValues.IntersectVisitor . |
abstract int |
getBytesPerDimension(String fieldName)
Returns the number of bytes per dimension
|
static int |
getDocCount(IndexReader reader,
String field)
Return the cumulated number of docs that have points across all leaves
of the given
IndexReader . |
abstract int |
getDocCount(String fieldName)
Returns the total number of documents that have indexed at least one point for this field.
|
static byte[] |
getMaxPackedValue(IndexReader reader,
String field)
Return the maximum packed values across all leaves of the given
IndexReader . |
abstract byte[] |
getMaxPackedValue(String fieldName)
Returns maximum value for each dimension, packed, or null if
size(org.apache.lucene.index.IndexReader, java.lang.String) is 0 |
static byte[] |
getMinPackedValue(IndexReader reader,
String field)
Return the minimum packed values across all leaves of the given
IndexReader . |
abstract byte[] |
getMinPackedValue(String fieldName)
Returns minimum value for each dimension, packed, or null if
size(org.apache.lucene.index.IndexReader, java.lang.String) is 0 |
abstract int |
getNumDimensions(String fieldName)
Returns how many dimensions were indexed
|
abstract void |
intersect(String fieldName,
PointValues.IntersectVisitor visitor)
Finds all documents and points matching the provided visitor.
|
static long |
size(IndexReader reader,
String field)
Return the cumulated number of points across all leaves of the given
IndexReader . |
abstract long |
size(String fieldName)
Returns the total number of indexed points across all documents in this field.
|
public static final int MAX_NUM_BYTES
public static final int MAX_DIMENSIONS
public static long size(IndexReader reader, String field) throws IOException
IndexReader
. Leaves that do not have points for the given field
are ignored.IOException
size(String)
public static int getDocCount(IndexReader reader, String field) throws IOException
IndexReader
. Leaves that do not have points for the
given field are ignored.IOException
getDocCount(String)
public static byte[] getMinPackedValue(IndexReader reader, String field) throws IOException
IndexReader
. Leaves that do not have points for the given field
are ignored.IOException
getMinPackedValue(String)
public static byte[] getMaxPackedValue(IndexReader reader, String field) throws IOException
IndexReader
. Leaves that do not have points for the given field
are ignored.IOException
getMaxPackedValue(String)
public abstract void intersect(String fieldName, PointValues.IntersectVisitor visitor) throws IOException
IOException
public abstract long estimatePointCount(String fieldName, PointValues.IntersectVisitor visitor)
intersect(java.lang.String, org.apache.lucene.index.PointValues.IntersectVisitor)
with the given PointValues.IntersectVisitor
. This should run many times faster
than intersect(String, IntersectVisitor)
.DocIdSetIterator.cost()
public abstract byte[] getMinPackedValue(String fieldName) throws IOException
size(org.apache.lucene.index.IndexReader, java.lang.String)
is 0
IOException
public abstract byte[] getMaxPackedValue(String fieldName) throws IOException
size(org.apache.lucene.index.IndexReader, java.lang.String)
is 0
IOException
public abstract int getNumDimensions(String fieldName) throws IOException
IOException
public abstract int getBytesPerDimension(String fieldName) throws IOException
IOException
public abstract long size(String fieldName)
public abstract int getDocCount(String fieldName)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.