Sort by location not working – Fatal Error
- prakashreddy.imduriParticipant2 years ago #32990
Then what can be the issue in our case, as I have also posted the results and the wpsolr query
prakashreddy.imduriParticipant2 years ago #32992I deleted that old field geolocation , and now using geolocation_acf everywhere.. those previous screenshots were old.
prakashreddy.imduriParticipant2 years ago #32994same error : can’t sort on geo_point field without using specific sorting feature, like geo_distance
prakashreddy.imduriParticipant2 years ago #32995getting same error on localhost too
wpsolrKeymaster2 years ago #32996Can you check in file wpsolr-pro/wpsolr/core/classes/engines/elasticsearch_php/class-wpsolr-searchelasticsearchclient.php, in function search_engine_client_add_sort_geolocation_distance, why the “if blocks” prevent the code adding the sort:
$sort_item = [ '_geo_distance' => [ $field_name => [ 'lat' => $geo_latitude, 'lon' => $geo_longitude ], 'order' => $sort_item[ $field_name ]['order'], 'unit' => 'km', 'mode' => 'min', 'distance_type' => 'plane', ], ];
prakashreddy.imduriParticipant2 years ago #32998I added these print statements, but nothing changed on the frontend
Seems it not getting into this function … the fatal error is still showing upprakashreddy.imduriParticipant2 years ago #32999I have added exit below 2 files :
in class-wpsolr-searchelasticsearchclient.php and class-wpsolr-abstractsearchclient.php,
but exit wasnt working in first php file, but exit was working in abstractsearchclient file, I found a code related to secondary sort not empty.
So, I turned off secondary sort which was set to most relevant, and now its working fine if we pass this url : ?s=&wpsolr_is_geo=y&wpsolr_sort=geolocation_acf_str_desc&wpsolr_lat=37.4580151&wpsolr_long=78.368766
Seems its a bug, secondary sort should work along geolocation. Isnt it ?
But when I click on sort filter in Sort Widget > Sort by geolocation desc or asc, no geo lat, long is getting passed
?s=&wpsolr_sort=geolocation_acf_str_asc
and its throwing same error [can’t sort on geo_point field without using specific sorting feature, like geo_distance]How can this be fixed now ? Location needs to be passed along with the sort widget also.. thats not happening right now
- This reply was modified 2 years ago by prakashreddy.imduri.
prakashreddy.imduriParticipant2 years ago #33002Yes removed secondary sort,
Issue is with the dropdown sort filter,
as its not passing on the latitude and longitude into the url, Can you check this and see the url you are getting.. Just a norrmal search page ?s=, and adding the location sort is taking me to this page : ?s=&wpsolr_sort=geolocation_acf_str_asc
and throwing previous error.
Location is already allowed in the browser.
Or Can you provide me a hook, where I can pass the lat, long by default when no lat.long is present- This reply was modified 2 years ago by prakashreddy.imduri.
prakashreddy.imduriParticipant2 years ago #33005yes, its secured and I am getting allow location poup, but only if I click on search.. If I use sort filters related to geolocation, the coordinates arent getting passed into url, neither its asking for any location permission access
wpsolrKeymaster2 years ago #33006You can use the option “Attach the geo localization js to your own search form(s)” to declare all search forms wich open the search url, including the top search form or the home search form.
The js script will add the lat,long parameters automatically to the search url and solve the geo sort issue.prakashreddy.imduriParticipant2 years ago #33007If you open the search page with ?s=, and directly use the sort by geolocation – ascending/descending , its a ajax call, and it wont ask for any location permission, just adds ‘wpsolr_sort=geolocation_acf_str_asc’ to the url, results remain unchanged here.
If you do search with some keyword and add then its asking for the location permission and adding it to url along with the wpsolr_sort, Now if you use any sorting related to location, when there is lat.long in url params, it sorts the results.Here are the settings we used:
You must be logged in to reply to this topic.