Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class PrefixTreeStrategy

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Inheritance
    object
    SpatialStrategy
    PrefixTreeStrategy
    RecursivePrefixTreeStrategy
    TermQueryPrefixTreeStrategy
    Inherited Members
    SpatialStrategy.m_ctx
    SpatialStrategy.SpatialContext
    SpatialStrategy.FieldName
    SpatialStrategy.MakeDistanceValueSource(IPoint)
    SpatialStrategy.MakeQuery(SpatialArgs)
    SpatialStrategy.MakeFilter(SpatialArgs)
    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.Prefix
    Assembly: Lucene.Net.Spatial.dll
    Syntax
    public abstract class PrefixTreeStrategy : SpatialStrategy

    Constructors

    PrefixTreeStrategy(SpatialPrefixTree, string, bool)

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    protected PrefixTreeStrategy(SpatialPrefixTree grid, string fieldName, bool simplifyIndexedCells)
    Parameters
    Type Name Description
    SpatialPrefixTree grid
    string fieldName
    bool simplifyIndexedCells

    Fields

    FIELD_TYPE

    Indexed, tokenized, not stored.

    Declaration
    public static readonly FieldType FIELD_TYPE
    Field Value
    Type Description
    FieldType

    m_defaultFieldValuesArrayLen

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    protected int m_defaultFieldValuesArrayLen
    Field Value
    Type Description
    int

    m_distErrPct

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    protected double m_distErrPct
    Field Value
    Type Description
    double

    m_grid

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    protected readonly SpatialPrefixTree m_grid
    Field Value
    Type Description
    SpatialPrefixTree

    m_simplifyIndexedCells

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    protected readonly bool m_simplifyIndexedCells
    Field Value
    Type Description
    bool

    Properties

    DefaultFieldValuesArrayLen

    A memory hint used by MakeDistanceValueSource(IPoint) for how big the initial size of each Document's array should be. The default is 2. Set this to slightly more than the default expected number of points per document.

    Declaration
    public virtual int DefaultFieldValuesArrayLen { get; set; }
    Property Value
    Type Description
    int

    DistErrPct

    The default measure of shape precision affecting shapes at index and query times.

    Declaration
    public virtual double DistErrPct { get; set; }
    Property Value
    Type Description
    double
    Remarks

    The default measure of shape precision affecting shapes at index and query times. Points don't use this as they are always indexed at the configured maximum precision (MaxLevels); this applies to all other shapes. Specific shapes at index and query time can use something different than this default value. If you don't set a default then the default is DEFAULT_DISTERRPCT -- 2.5%.

    See Also
    DistErrPct

    Grid

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    public virtual SpatialPrefixTree Grid { get; }
    Property Value
    Type Description
    SpatialPrefixTree

    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.

    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

    CreateIndexableFields(IShape?, double)

    An abstract SpatialStrategy based on SpatialPrefixTree. The two subclasses are RecursivePrefixTreeStrategy and TermQueryPrefixTreeStrategy. This strategy is most effective as a fast approximate spatial search filter.

    Characteristics:

    • Can index any shape; however only RecursivePrefixTreeStrategy can effectively search non-point shapes.
    • Can index a variable number of shapes per field value. This strategy can do it via multiple calls to CreateIndexableFields(IShape) for a document or by giving it some sort of Shape aggregate (e.g. NTS WKT MultiPoint). The shape's boundary is approximated to a grid precision.
    • Can query with any shape. The shape's boundary is approximated to a grid precision.
    • Only Intersects is supported. If only points are indexed then this is effectively equivalent to IsWithin.
    • The strategy supports MakeDistanceValueSource(IPoint, double) even for multi-valued data, so long as the indexed data is all points; the behavior is undefined otherwise. However, it will likely be removed in the future in lieu of using another strategy with a more scalable implementation. Use of this call is the only circumstance in which a cache is used. The cache is simple but as such it doesn't scale to large numbers of points nor is it real-time-search friendly.

    Implementation:

    The SpatialPrefixTree does most of the work, for example returning a list of terms representing grids of various sizes for a supplied shape. An important configuration item is DistErrPct which balances shape precision against scalability. See those docs.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Declaration
    public virtual Field[] CreateIndexableFields(IShape? shape, double distErr)
    Parameters
    Type Name Description
    IShape shape
    double distErr
    Returns
    Type Description
    Field[]

    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)
    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.