public class PointVectorStrategy extends SpatialStrategy
SpatialStrategy which represents Points in two numeric DoubleFields. The Strategy's best feature is decent distance sort.
SpatialOperation.Intersects and SpatialOperation.IsWithin is supported.makeDistanceValueSource(com.spatial4j.core.shape.Point) and for
searching with a Circle.NumericRangeQuerys on
an x & y pair of fields. A Circle query does the same bbox query but adds a
ValueSource filter on
makeDistanceValueSource(com.spatial4j.core.shape.Point).
One performance shortcoming with this strategy is that a scenario involving
both a search using a Circle and sort will result in calculations for the
spatial distance being done twice -- once for the filter and second for the
sort.| Modifier and Type | Field and Description |
|---|---|
int |
precisionStep |
static String |
SUFFIX_X |
static String |
SUFFIX_Y |
ctx| Constructor and Description |
|---|
PointVectorStrategy(com.spatial4j.core.context.SpatialContext ctx,
String fieldNamePrefix) |
| Modifier and Type | Method and Description |
|---|---|
Field[] |
createIndexableFields(com.spatial4j.core.shape.Point point) |
Field[] |
createIndexableFields(com.spatial4j.core.shape.Shape shape)
Returns the IndexableField(s) from the
shape that are to be
added to the Document. |
ValueSource |
makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint)
Make a ValueSource returning the distance between the center of the
indexed shape and
queryPoint. |
Filter |
makeFilter(SpatialArgs args)
|
ConstantScoreQuery |
makeQuery(SpatialArgs args)
|
Query |
makeQueryDistanceScore(SpatialArgs args) |
void |
setPrecisionStep(int p) |
getFieldName, getSpatialContext, makeRecipDistanceValueSource, toStringpublic static final String SUFFIX_X
public static final String SUFFIX_Y
public int precisionStep
public PointVectorStrategy(com.spatial4j.core.context.SpatialContext ctx,
String fieldNamePrefix)
public void setPrecisionStep(int p)
public Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)
SpatialStrategyshape that are to be
added to the Document. These fields
are expected to be marked as indexed and not stored.
Note: If you want to store the shape as a string for retrieval in
search results, you could add it like this:
document.add(new StoredField(fieldName,ctx.toString(shape)));The particular string representation used doesn't matter to the Strategy since it doesn't use it.
createIndexableFields in class SpatialStrategypublic Field[] createIndexableFields(com.spatial4j.core.shape.Point point)
public ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint)
SpatialStrategyqueryPoint. If there are multiple indexed shapes
then the closest one is chosen.makeDistanceValueSource in class SpatialStrategypublic Filter makeFilter(SpatialArgs args)
SpatialStrategySpatialOperation
and Shape from the supplied args.
If a subclasses implements
SpatialStrategy.makeQuery(org.apache.lucene.spatial.query.SpatialArgs)
then this method could be simply:
return new QueryWrapperFilter(makeQuery(args).getQuery());
makeFilter in class SpatialStrategypublic ConstantScoreQuery makeQuery(SpatialArgs args)
SpatialStrategySpatialOperation
and Shape from the supplied args.
The default implementation is
return new ConstantScoreQuery(makeFilter(args));
makeQuery in class SpatialStrategypublic Query makeQueryDistanceScore(SpatialArgs args)
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.