Class PointVectorStrategy
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Spatial.Vector
Assembly: Lucene.Net.Spatial.dll
Syntax
public class PointVectorStrategy : SpatialStrategy
Constructors
PointVectorStrategy(SpatialContext, string)
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public PointVectorStrategy(SpatialContext ctx, string fieldNamePrefix)
Parameters
Type | Name | Description |
---|---|---|
SpatialContext | ctx | |
string | fieldNamePrefix |
Fields
SUFFIX_X
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public const string SUFFIX_X = "__x"
Field Value
Type | Description |
---|---|
string |
SUFFIX_Y
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public const string SUFFIX_Y = "__y"
Field Value
Type | Description |
---|---|
string |
Properties
PrecisionStep
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual int PrecisionStep { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
CreateIndexableFields(IPoint)
Declaration
public virtual Field[] CreateIndexableFields(IPoint point)
Parameters
Type | Name | Description |
---|---|---|
IPoint | point |
Returns
Type | Description |
---|---|
Field[] |
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)
Make a Filter based principally on SpatialOperation
and Spatial4n.Shapes.IShape from the supplied args
.
return new QueryWrapperFilter(MakeQuery(args).Query);
Declaration
public override Filter MakeFilter(SpatialArgs args)
Parameters
Type | Name | Description |
---|---|---|
SpatialArgs | args |
Returns
Type | Description |
---|---|
Filter |
Overrides
Exceptions
Type | Condition |
---|---|
NotSupportedException | If the strategy does not support the shape in |
UnsupportedSpatialOperationException | If the strategy does not support the SpatialOperation in |
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 |
MakeQueryDistanceScore(SpatialArgs)
Simple SpatialStrategy which represents Points in two numeric Lucene.Net.Documents.DoubleFields. The Strategy's best feature is decent distance sort.
Characteristics:
- Only indexes points; just one per field value.
- Can query by a rectangle or circle.
- Intersects and IsWithin is supported.
- Uses the FieldCache for MakeDistanceValueSource(IPoint) and for searching with a Circle.
Implementation:
This is a simple Strategy. Search works with Lucene.Net.Search.NumericRangeQuerys on an x & y pair of fields. A Circle query does the same bbox query but adds a ValueSource filter on MakeDistanceValueSource(IPoint). 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.Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public virtual Query MakeQueryDistanceScore(SpatialArgs args)
Parameters
Type | Name | Description |
---|---|---|
SpatialArgs | args |
Returns
Type | Description |
---|---|
Query |