solr-spatial-field search backend errors when searching across the anti-meridian
- Dominant language
- XSLT
- Stars
- 136
- Forks
- 207
- PR merge metrics
- No merged PRs in 30d
Description
# Context
Tested using CKAN 2.7.4 and solr 6.5 with the JTS 1.14 plugin and the solr-spatial-field configured in the schema.xml.
# Issue
When using the solr-spatial-field search backend, and querying across the anti-meridian I.E https://demo.ckan.org/dataset?ext_bbox=177,-38,184,-37 then the query generated for solr will return a 400 http response.
The problem is that the `ENVELOPE` part of the query has a `maxx` value that is greater than 180. when solr expects the value to be between -180 and 180.
# Solution
In the `_params_for_solr_spatial_field_search` method, we could move the value into the expected bounds.
```py
def _params_for_solr_spatial_field_search(self, bbox, search_params):
'''
This will add an fq filter with the form:
+spatial_geom:"Intersects(ENVELOPE({minx}, {miny}, {maxx}, {maxy}))
'''
if bbox['maxx'] > 180:
bbox['maxx'] = -180 + (bbox['maxx'] - 180)
search_params['fq_list'] = search_params.get('fq_list', [])
search_params['fq_list'].append('+spatial_geom:"Intersects(ENVELOPE({minx}, {maxx}, {maxy}, {miny}))"'
.format(minx=bbox['minx'], miny=bbox['miny'], maxx=bbox['maxx'], maxy=bbox['maxy']))
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the `_params_for_solr_spatial_field_search` method and inspect how the bounding box becomes the Solr `ENVELOPE` query. Reproduce the demo query `ext_bbox=177,-38,184,-37` against the solr-spatial-field configuration in `schema.xml`; done means the generated query keeps longitude values within Solr's -180 to 180 bounds and no longer returns HTTP 400.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100