Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Namespace Lucene.Net.Spatial

    The Spatial Module for Apache Lucene.NET

    The spatial module is new to Lucene.NET 4, replacing the old "Lucene.Net.Contrib" module that came before it. The principle interface to the module is a SpatialStrategy which encapsulates an approach to indexing and searching based on shapes. Different Strategies have different features and performance profiles, which are documented at each Strategy implementation class level.

    For some sample code showing how to use the API, see SpatialExample.cs in the tests.

    The spatial module uses Spatial4n, a .NET port of the ASL licensed Spatial4j heavily. Spatial4n is a library with these capabilities:

    • Provides shape implementations, namely point, rectangle, and circle. Both geospatial contexts and plain 2D Euclidean/Cartesian contexts are supported. With an additional dependency, it adds polygon and other geometry shape support via integration with NetTopologySuite (often referred to as NTS). This includes dateline wrap support.
    • Shape parsing and serialization, including Well-Known Text (WKT) (via NTS).
    • Distance and other spatial related math calculations.
    Note

    Historical Fact: The new spatial module was once known as Lucene Spatial Playground (LSP) as an external project. In ~March 2012, LSP split into this new module as part of Lucene and Spatial4j externally. A large chunk of the LSP implementation originated as SOLR-2155 which uses trie/prefix-tree algorithms with a geohash encoding. That approach is implemented in RecursivePrefixTreeStrategy today.

    Classes

    DisjointSpatialFilter

    A Spatial Filter implementing IsDisjointTo in terms of a SpatialStrategy's support for Intersects. A document is considered disjoint if it has spatial data that does not intersect with the query shape. Another way of looking at this is that it's a way to invert a query shape.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    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 Lucene.Net.Search.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.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    • Improve this Doc
    Back to top Copyright © 2022 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.