Rename solr backend to solr-bbox for clarity

This commit is contained in:
amercader 2022-10-06 11:19:38 +02:00
parent b1aaff269e
commit ef8c3c1134
3 changed files with 29 additions and 21 deletions

View File

@ -33,9 +33,10 @@ config = tk.config
log = getLogger(__name__)
DEFAULT_SEARCH_BACKEND = "solr"
DEFAULT_SEARCH_BACKEND = "solr-bbox"
ALLOWED_SEARCH_BACKENDS = [
"solr",
"solr", # Deprecated, please update to "solr-bbox"
"solr-bbox",
"solr-spatial-field",
"postgis", # Deprecated: will be removed in the next version
]
@ -184,9 +185,14 @@ class SpatialQuery(SpatialQueryMixin, p.SingletonPlugin):
search_backend, ALLOWED_SEARCH_BACKENDS)
)
if search_backend == "postgis":
if search_backend == "solr":
log.warning(
"The `postgis` spatial search backend is deprecated"
"The `solr` spatial search backend has been renamed to `solr-bbox`, "
"please update your configuration"
)
elif search_backend == "postgis":
log.warning(
"The `postgis` spatial search backend is deprecated "
"and will be removed in future versions"
)
@ -213,7 +219,7 @@ class SpatialQuery(SpatialQueryMixin, p.SingletonPlugin):
search_backend = self._get_search_backend()
if search_backend not in ('solr', 'solr-spatial-field'):
if search_backend not in ("solr-bbox", "solr-spatial-field"):
return pkg_dict
if not pkg_dict.get('extras_spatial'):
@ -240,7 +246,7 @@ class SpatialQuery(SpatialQueryMixin, p.SingletonPlugin):
log.error('{}, not indexing :: {}'.format(e, geom_from_metadata[:100]))
return pkg_dict
if search_backend == 'solr':
if search_backend == "solr-bbox":
# We always index the envelope of the geometry regardless of
# if it's an actual bounding box (polygon)
@ -311,7 +317,7 @@ you need to split the geometry in order to fit the parts. Not indexing""")
if not bbox:
raise SearchError('Wrong bounding box provided')
if search_backend in ('solr', 'solr-spatial-field'):
if search_backend in ("solr-bbox", "solr-spatial-field"):
bbox = fit_bbox(bbox)
@ -319,7 +325,7 @@ you need to split the geometry in order to fit the parts. Not indexing""")
search_params["fq_list"] = []
spatial_field = (
"spatial_bbox" if search_backend == "solr" else "spatial_geom"
"spatial_bbox" if search_backend == "solr-bbox" else "spatial_geom"
)
default_spatial_query = "{{!field f={spatial_field}}}Intersects(ENVELOPE({minx}, {maxx}, {maxy}, {miny}))"

View File

@ -35,7 +35,7 @@ extents = {
@pytest.mark.usefixtures("clean_db", "clean_index", "harvest_setup", "with_plugins")
@pytest.mark.ckan_config("ckanext.spatial.search_backend", "solr")
@pytest.mark.ckan_config("ckanext.spatial.search_backend", "solr-bbox")
class TestBBoxSearch(SpatialTestBase):
def test_spatial_query(self):
dataset = factories.Dataset(
@ -275,7 +275,7 @@ class TestBBoxSearch(SpatialTestBase):
)
assert result["count"] == 0
def test_geometry_collection(self):
""" Test a geometry collection """

View File

@ -113,24 +113,26 @@ There are different backends supported for the spatial search, it is important
to understand their differences and the necessary setup required when choosing
which one to use. To configure the search backend use the following configuration option::
ckanext.spatial.search_backend = solr | solr-spatial-field
ckanext.spatial.search_backend = solr-bbox | solr-spatial-field
The following table summarizes the different spatial search backends:
+------------------------+--------------------------------------+--------------------+
| Backend | Supported geometries indexed in Solr | Solr setup needed |
+========================+======================================+====================+
| ``solr`` | Bounding Box | Custom field |
+------------------------+--------------------------------------+--------------------+
| ``solr-spatial-field`` | Bounding Box, Point and Polygon | Custom field + JTS |
+------------------------+--------------------------------------+--------------------+
+-------------------------+--------------------------------------+--------------------+
| Backend | Supported geometries indexed in Solr | Solr setup needed |
+=========================+======================================+====================+
| ``solr-bbox`` (default) | Bounding Box | Custom field |
+-------------------------+--------------------------------------+--------------------+
| ``solr-spatial-field`` | Bounding Box, Point and Polygon | Custom field + JTS |
+-------------------------+--------------------------------------+--------------------+
.. note:: The default ``solr-bbox`` search backend was previously known as ``solr``. Please update
your configuration if using this version as it will be removed in the future.
The ``solr`` backend is probably a good starting point. Here are more
The ``solr-bbox`` backend is probably a good starting point. Here are more
details about the available options (again, you don't need to modify Solr if you are using one of the spatial enabled official Docker images):
* ``solr``
* ``solr-bbox``
This option always indexes just the extent of the provided geometries, whether if it's an
actual bounding box or not. It uses Solr's `BBoxField <https://solr.apache.org/guide/8_11/spatial-search.html#bboxfield>`_ so you need to add the following to your Solr schema::