In a Sorl index based view, I want to sort the results on the distance to the given location. The view uses an exposed filter. The field is of Geofield type. The two Views field types ("{Field name} (distance)" and "{Field name} (indexed field) - distance"), both give the same error. The error only occurs when the Location filter input empty.
An error occurred while trying to search with Solr: {"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"msg":"Sorting not supported on LatLonType locs_field_lat_lon__distance","code":400}} .
The Readme does not provide addition info.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | search_api_location-2954279-7-sorting-with-empty-location.patch | 4.06 KB | mollux |
Comments
Comment #2
dbjpanda commentedHi @Sutharsan I have just compiled all the patches into one patch. Its working fine for me. I can sort as well. You can have a try.
If you want to apply the patches individually then try these order.
1 - https://www.drupal.org/project/search_api_location/issues/2878726#commen...
2- https://www.drupal.org/project/search_api_location/issues/2905431#commen...
3- https://www.drupal.org/project/search_api_location/issues/2913666
4- https://www.drupal.org/project/search_api_location/issues/2954999
Comment #3
dbjpanda commentedComment #4
strykaizerI'm experiencing the same issue.
Once I add an extra sort on my search api views page, on distance, I have no results anymore.
I'm using dev version (tried with last beta too).
Comment #5
sutharsan commentedThe error only occurs when the search input is empty.
Changing category to 'bug report'
The patches 2905431 and 2954999 in #2 do not solve the error. (2878726 already comitted, 2913666 not tested)
Comment #6
sutharsan commentedComment #7
mollux commentedI was able to reproduce this, and it is an interesting bug.
When adding sorting on distance, there is no check if there is actually any spatial information available in the query.
This is the case with an empty exposed spatial filter, or when no spatial filter is added.
I Fixed this by overriding the sort plugin for the distance field, so sorting on distance can be skipped when no spatial info is available.
I also removed the filter on the distance pseudo field, as distance filtering is what is done by the spatial filter.
There is 1 caveat, I currently have to guess the name of the distance field, as the backend doesn't provide that info.
I also want to add a test for this, but still figuring out the bast approach for this.
@stryKaizer and @Sutharsan, can you try the patch and give some feedback?
No additional patches are necessary with the latest dev release.
Comment #8
strykaizerPatch in #7 fixes empty distance search. Thx!
Comment #10
mollux commentedThanks for the feedback.
Committed!