C# Класс 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
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
ctx Spatial4n.Core.Context.SpatialContext

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
SpatialStrategy ( SpatialContext ctx, string fieldName ) : Lucene.Net.Documents

Constructs the spatial strategy with its mandatory arguments.

Описание методов

CreateIndexableFields() публичный абстрактный Метод

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
Результат Lucene.Net.Documents.Field[]

MakeDistanceValueSource() публичный Метод

See MakeDistanceValueSource(IPoint, double) called with a multiplier of 1.0 (i.e. units of degrees).
public MakeDistanceValueSource ( IPoint queryPoint ) : ValueSource
queryPoint IPoint
Результат ValueSource

MakeDistanceValueSource() публичный абстрактный Метод

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
Результат ValueSource

MakeFilter() публичный абстрактный Метод

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
Результат Lucene.Net.Search.Filter

MakeQuery() публичный Метод

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
Результат Lucene.Net.Search.ConstantScoreQuery

MakeRecipDistanceValueSource() публичный Метод

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
Результат ValueSource

SpatialStrategy() защищенный Метод

Constructs the spatial strategy with its mandatory arguments.
protected SpatialStrategy ( SpatialContext ctx, string fieldName ) : Lucene.Net.Documents
ctx Spatial4n.Core.Context.SpatialContext
fieldName string
Результат Lucene.Net.Documents

ToString() публичный Метод

public ToString ( ) : string
Результат string

Описание свойств

ctx защищенное свойство

protected SpatialContext,Spatial4n.Core.Context ctx
Результат Spatial4n.Core.Context.SpatialContext