public class BBoxStrategy extends SpatialStrategy
SpatialOperation
s and
has a custom overlap relevancy. It is based on GeoPortal's SpatialClauseAdapter.
SpatialOperation
s but not Overlaps.SpatialOperation
s, there are a variety of NumericRangeQuery
s to be
done.
The makeOverlapRatioValueSource(com.spatial4j.core.shape.Rectangle, double)
works by calculating the query bbox overlap percentage against the indexed
shape overlap percentage. The indexed shape's coordinates are retrieved from
AtomicReader.getNumericDocValues(java.lang.String)
.Modifier and Type | Field and Description |
---|---|
protected String |
field_bbox |
protected String |
field_maxX |
protected String |
field_maxY |
protected String |
field_minX |
protected String |
field_minY |
protected String |
field_xdl |
protected FieldType |
fieldType |
static String |
SUFFIX_MAXX |
static String |
SUFFIX_MAXY |
static String |
SUFFIX_MINX |
static String |
SUFFIX_MINY |
static String |
SUFFIX_XDL |
protected FieldType |
xdlFieldType |
ctx
Constructor and Description |
---|
BBoxStrategy(com.spatial4j.core.context.SpatialContext ctx,
String fieldNamePrefix) |
Modifier and Type | Method and Description |
---|---|
Field[] |
createIndexableFields(com.spatial4j.core.shape.Rectangle bbox) |
Field[] |
createIndexableFields(com.spatial4j.core.shape.Shape shape)
Returns the IndexableField(s) from the
shape that are to be
added to the Document . |
FieldType |
getFieldType() |
ValueSource |
makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint,
double multiplier)
Make a ValueSource returning the distance between the center of the
indexed shape and
queryPoint . |
Filter |
makeFilter(SpatialArgs args)
|
ValueSource |
makeOverlapRatioValueSource(com.spatial4j.core.shape.Rectangle queryBox,
double queryTargetProportion)
Returns a similarity based on
BBoxOverlapRatioValueSource . |
ConstantScoreQuery |
makeQuery(SpatialArgs args)
|
ValueSource |
makeShapeValueSource()
Provides access to each rectangle per document as a ValueSource in which
FunctionValues.objectVal(int) returns a Shape . |
void |
setFieldType(FieldType fieldType)
Used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL field too.
|
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
public static final String SUFFIX_MINX
public static final String SUFFIX_MAXX
public static final String SUFFIX_MINY
public static final String SUFFIX_MAXY
public static final String SUFFIX_XDL
protected final String field_bbox
protected final String field_minX
protected final String field_minY
protected final String field_maxX
protected final String field_maxY
protected final String field_xdl
protected FieldType fieldType
protected FieldType xdlFieldType
public BBoxStrategy(com.spatial4j.core.context.SpatialContext ctx, String fieldNamePrefix)
public FieldType getFieldType()
public void setFieldType(FieldType fieldType)
FieldType.freeze()
is called on the argument.public Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)
SpatialStrategy
shape
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 SpatialStrategy
public Field[] createIndexableFields(com.spatial4j.core.shape.Rectangle bbox)
public ValueSource makeShapeValueSource()
FunctionValues.objectVal(int)
returns a Shape
.public ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint, double multiplier)
SpatialStrategy
queryPoint
. If there are multiple indexed shapes
then the closest one is chosen. The result is multiplied by multiplier
, which
conveniently is used to get the desired units.makeDistanceValueSource
in class SpatialStrategy
public ValueSource makeOverlapRatioValueSource(com.spatial4j.core.shape.Rectangle queryBox, double queryTargetProportion)
BBoxOverlapRatioValueSource
. This is just a
convenience method.public Filter makeFilter(SpatialArgs args)
SpatialStrategy
SpatialOperation
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 SpatialStrategy
public ConstantScoreQuery makeQuery(SpatialArgs args)
SpatialStrategy
SpatialOperation
and Shape
from the supplied args
.
The default implementation is
return new ConstantScoreQuery(makeFilter(args));
makeQuery
in class SpatialStrategy
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.