1

I have some entries to filter with geo location in stores channel. I want to filter all the stores near my zip code between some miles. I implemented it with geo coder and distance filter of low search and it working fine too except the sort order.

All the entries are displaying in random order of distance. for an example:

Shop 1 : 7 ml away
Shop 2 : 20 ml away
Shop 3 : 5 ml away

I want to list the entries in asc order of distance so the output sholud be:

Shop 3 : 5 ml away
Shop 1 : 7 ml away
Shop 2 : 20 ml away

Let me know if I do something wrong.

My Form page query is:

{exp:low_search:form query="{segment_3}" result_page="/stores/search-results/" form_id="search_stores" collections="stores"}
    <input type="hidden" id="location" name="distance:from" value="">
    <input type="hidden" name="distance:radius" value="200">
    <input type="hidden" name="distance:unit" value="mi">
    <input type="text" name="search:store_country" value=""> {!--Country field of channel entry--}
    <input type="text" type="keywords" name="keywords" value="{low_search_keywords}">

    <input type="submit" name="submit" value="Search">
{/exp:low_search:form}

My query string get from form is /?distance:from={my_lat}|{my_long}&distance:unit=mi&keywords={keywords}&distance:radius=200&search:store_country={country}

My result query is:

{exp:low_search:results query="{segment_3}" distance:to="store_latitude|store_longitude" channel="stores" collections="stores" require_all="category" limit="6" paginate="bottom"}
    <p>{title}: {low_search_distance} ml away</p>
{/exp:low_search:results}

(Asc order of low search geo location is working if I dont use KEYWORDS and use any other variable)

2
  • 1
    Can you post the code for your Form tag, as well as an example of your encoded query (so the ey... string)? – Low Apr 6 '17 at 7:23
  • Hello @Low, I've updated my question. Please review. – Mufi - Amici Infotech Apr 6 '17 at 12:16
1

This is intended behaviour. If you search by keywords and distance, then the search results will automatically be ordered by relevance score (which is the last filter to be fired). If you want to explicitly order by distance, you can set the orderby parameter on the Results tag like so:

orderby="low_search_distance"

...or add this to your Form:

<input type="hidden" name="orderby" value="low_search_distance">
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.