C# Class Lucene.Net.Spatial.SpatialStrategy

The SpatialStrategy encapsulates an approach to indexing and searching based on shapes. Different implementations will support different features. A strategy should document these common elements: Can it index more than one shape per field? What types of shapes can be indexed? What types of query shapes can be used? What types of query operations are supported? This might vary per shape. Does it use the FieldCache, or some other type of cache? When? If a strategy only supports certain shapes at index or query time, then in general it will throw an exception if given an incompatible one. It will not be coerced into compatibility. Note that a SpatialStrategy is not involved with the Lucene stored field values of shapes, which is immaterial to indexing and search. Thread-safe. @lucene.experimental
Show file Open project: apache/lucenenet Class Usage Examples

Protected Properties

Property Type Description
ctx Spatial4n.Core.Context.SpatialContext

Public Methods

Method Description
CreateIndexableFields ( IShape shape ) : Lucene.Net.Documents.Field[]

Returns the IndexableField(s) from the 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.

MakeDistanceValueSource ( IPoint queryPoint ) : ValueSource

See MakeDistanceValueSource(IPoint, double) called with a multiplier of 1.0 (i.e. units of degrees).

MakeDistanceValueSource ( IPoint queryPoint, double multiplier ) : ValueSource

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.

MakeFilter ( SpatialArgs args ) : Filter

Make a Filter based principally on SpatialOperation and IShape from the supplied args. If a subclasses implements MakeQuery(SpatialArgs) then this method could be simply: return new QueryWrapperFilter(MakeQuery(args).Query);

MakeQuery ( SpatialArgs args ) : ConstantScoreQuery

Make a Query based principally on SpatialOperation and IShape from the supplied args. The default implementation is return new ConstantScoreQuery(MakeFilter(args));

MakeRecipDistanceValueSource ( IShape queryShape ) : ValueSource

Returns a ValueSource with values ranging from 1 to 0, depending inversely on the distance from MakeDistanceValueSource(IPoint). The formula is c / (d + c) where 'd' is the distance and 'c' is one tenth the distance to the farthest edge from the center. Thus the scores will be 1 for indexed points at the center of the query shape and as low as ~0.1 at its furthest edges.

ToString ( ) : string

Protected Methods

Method Description
SpatialStrategy ( SpatialContext ctx, string fieldName ) : Lucene.Net.Documents

Constructs the spatial strategy with its mandatory arguments.

Method Details

CreateIndexableFields() public abstract method

Returns the IndexableField(s) from the 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.

if given a shape incompatible with the strategy
public abstract CreateIndexableFields ( IShape shape ) : Lucene.Net.Documents.Field[]
shape IShape
return Lucene.Net.Documents.Field[]

MakeDistanceValueSource() public method

See MakeDistanceValueSource(IPoint, double) called with a multiplier of 1.0 (i.e. units of degrees).
public MakeDistanceValueSource ( IPoint queryPoint ) : ValueSource
queryPoint IPoint
return ValueSource

MakeDistanceValueSource() public abstract method

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.
public abstract MakeDistanceValueSource ( IPoint queryPoint, double multiplier ) : ValueSource
queryPoint IPoint
multiplier double
return ValueSource

MakeFilter() public abstract method

Make a Filter based principally on SpatialOperation and IShape from the supplied args. If a subclasses implements MakeQuery(SpatialArgs) then this method could be simply: return new QueryWrapperFilter(MakeQuery(args).Query);
If the strategy does not support the shape in . If the strategy does not support the in .
public abstract MakeFilter ( SpatialArgs args ) : Filter
args Lucene.Net.Spatial.Queries.SpatialArgs
return Lucene.Net.Search.Filter

MakeQuery() public method

Make a Query based principally on SpatialOperation and IShape from the supplied args. The default implementation is return new ConstantScoreQuery(MakeFilter(args));
If the strategy does not support the shape in . If the strategy does not support the in .
public MakeQuery ( SpatialArgs args ) : ConstantScoreQuery
args Lucene.Net.Spatial.Queries.SpatialArgs
return Lucene.Net.Search.ConstantScoreQuery

MakeRecipDistanceValueSource() public method

Returns a ValueSource with values ranging from 1 to 0, depending inversely on the distance from MakeDistanceValueSource(IPoint). The formula is c / (d + c) where 'd' is the distance and 'c' is one tenth the distance to the farthest edge from the center. Thus the scores will be 1 for indexed points at the center of the query shape and as low as ~0.1 at its furthest edges.
public MakeRecipDistanceValueSource ( IShape queryShape ) : ValueSource
queryShape IShape
return ValueSource

SpatialStrategy() protected method

Constructs the spatial strategy with its mandatory arguments.
protected SpatialStrategy ( SpatialContext ctx, string fieldName ) : Lucene.Net.Documents
ctx Spatial4n.Core.Context.SpatialContext
fieldName string
return Lucene.Net.Documents

ToString() public method

public ToString ( ) : string
return string

Property Details

ctx protected property

protected SpatialContext,Spatial4n.Core.Context ctx
return Spatial4n.Core.Context.SpatialContext