Sort by location not working – Fatal Error

  • 10 months, 2 weeks ago #32990

    Then what can be the issue in our case, as I have also posted the results and the wpsolr query

    10 months, 2 weeks ago #32991

    Your examples show an ACF field “geolocation_acf”, but also a field “geolocation”. Please setup “geolocation_acf” everywhere: screen 2.2, and sorts screen.

    10 months, 2 weeks ago #32992

    I deleted that old field geolocation , and now using geolocation_acf everywhere.. those previous screenshots were old.

    10 months, 2 weeks ago #32993

    Can you try with the same search url as mine?

    10 months, 2 weeks ago #32994

    same error : can’t sort on geo_point field without using specific sorting feature, like geo_distance

    10 months, 2 weeks ago #32995

    getting same error on localhost too

    10 months, 2 weeks ago #32996

    Can 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',
    10 months, 2 weeks ago #32998

    I added these print statements, but nothing changed on the frontend
    Seems it not getting into this function … the fatal error is still showing up

    10 months, 2 weeks ago #32999

    I 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
    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

    10 months, 2 weeks ago #33001

    It looks like the second sort does not work with Elasticsearch first geolocation sort.

    Remove the second sort in your “2.5 Sort” settings, all your previous debug code, and all should be working fine, including the widget sort (I just tested).

    10 months, 2 weeks ago #33002

    Yes 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

    10 months, 2 weeks ago #33004

    Your site must be secured (https) to enable the js script to get your location and add it to the url.
    The user’s authorisation must also be activated in the WPSOLR Geolocation add-on.

    10 months, 2 weeks ago #33005

    yes, 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

    10 months, 2 weeks ago #33006

    You 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.

    10 months, 2 weeks ago #33007

    If 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:

Viewing 15 posts - 16 through 30 (of 37 total)

You must be logged in to reply to this topic.