Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    SpatialStrategy
    PointVectorStrategy
    Inherited Members
    SpatialStrategy.m_ctx
    SpatialStrategy.SpatialContext
    SpatialStrategy.FieldName
    SpatialStrategy.MakeDistanceValueSource(IPoint)
    SpatialStrategy.MakeRecipDistanceValueSource(IShape)
    SpatialStrategy.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    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)

    See CreateIndexableFields(IShape)

    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.

    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.
    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
    SpatialStrategy.CreateIndexableFields(IShape)
    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
    SpatialStrategy.MakeDistanceValueSource(IPoint, double)

    MakeFilter(SpatialArgs)

    Make a Filter based principally on SpatialOperation and Spatial4n.Shapes.IShape from the supplied args.

    If a subclasses implements MakeQuery(SpatialArgs) then this method could be simply:
    return new QueryWrapperFilter(MakeQuery(args).Query);
    Declaration
    public override Filter MakeFilter(SpatialArgs args)
    Parameters
    Type Name Description
    SpatialArgs args
    Returns
    Type Description
    Filter
    Overrides
    SpatialStrategy.MakeFilter(SpatialArgs)
    Exceptions
    Type Condition
    NotSupportedException

    If the strategy does not support the shape in args.

    UnsupportedSpatialOperationException

    If the strategy does not support the SpatialOperation in args.

    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
    SpatialStrategy.MakeQuery(SpatialArgs)
    Exceptions
    Type Condition
    NotSupportedException

    If the strategy does not support the shape in args.

    UnsupportedSpatialOperationException

    If the strategy does not support the SpatialOperation in args.

    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
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.