Class SerializedDVStrategy
A SpatialStrategy based on serializing a Shape stored into BinaryDocValues. This is not at all fast; it's designed to be used in conjuction with another index based SpatialStrategy that is approximated(like RecursivePrefixTreeStrategy) to add precision or eventually make more specific / advanced calculations on the per-document geometry. The serialization uses Spatial4j's Spatial4n.IO.BinaryCodec.
Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Spatial.Serialized
Assembly: Lucene.Net.Spatial.dll
Syntax
public class SerializedDVStrategy : SpatialStrategy
Constructors
SerializedDVStrategy(SpatialContext, string)
Constructs the spatial strategy with its mandatory arguments.
Declaration
public SerializedDVStrategy(SpatialContext ctx, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
SpatialContext | ctx | |
string | fieldName |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Methods
CreateIndexableFields(IShape)
Returns the IndexableField(s) from the shape
that are to be
added to the Lucene.Net.Documents.Document. These fields
are expected to be marked as indexed and not stored.
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.
Declaration
public override Field[] CreateIndexableFields(IShape shape)
Parameters
Type | Name | Description |
---|---|---|
IShape | shape |
Returns
Type | Description |
---|---|
Field[] | Not null nor will it have null elements. |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | if given a shape incompatible with the strategy |
MakeDistanceValueSource(IPoint, double)
Make a ValueSource returning the distance between the center of the
indexed shape and 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.
Declaration
public override ValueSource MakeDistanceValueSource(IPoint queryPoint, double multiplier)
Parameters
Type | Name | Description |
---|---|---|
IPoint | queryPoint | |
double | multiplier |
Returns
Type | Description |
---|---|
ValueSource |
Overrides
MakeFilter(SpatialArgs)
Returns a Lucene.Net.Search.Filter that should be used with Lucene.Net.Search.FilteredQuery.QUERY_FIRST_FILTER_STRATEGY. Use in another manner is likely to result in an NotSupportedException to prevent misuse because the filter can't efficiently work via iteration.
Declaration
public override Filter MakeFilter(SpatialArgs args)
Parameters
Type | Name | Description |
---|---|---|
SpatialArgs | args |
Returns
Type | Description |
---|---|
Filter |
Overrides
MakeQuery(SpatialArgs)
Make a Query based principally on SpatialOperation
and Spatial4n.Shapes.IShape from the supplied args
.
The default implementation is
return new ConstantScoreQuery(MakeFilter(args));
Declaration
public override ConstantScoreQuery MakeQuery(SpatialArgs args)
Parameters
Type | Name | Description |
---|---|---|
SpatialArgs | args |
Returns
Type | Description |
---|---|
ConstantScoreQuery |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | If the strategy does not support the shape in |
UnsupportedSpatialOperationException | If the strategy does not support the SpatialOperation in |
MakeShapeValueSource()
Provides access to each shape per document as a ValueSource in which ObjectVal(int) returns a Spatial4n.Shapes.IShape.
Declaration
public virtual ValueSource MakeShapeValueSource()
Returns
Type | Description |
---|---|
ValueSource |