#community-help

Resolving Search Query Issue for Nearest Product Selection

TLDR Ramees asked for help on product search query problem. Jason provided a solution, which Ramees confirmed as successful.

Powered by Struct AI

1

1

9
27mo
Solved
Join the chat
Aug 23, 2021 (27 months ago)
Ramees
Photo of md5-ddfa968eca4266b70a36c83bdcdc7b94
Ramees
05:05 PM
Hi, I have a Collection of products with name and Geo-location as fields.

When performing search, result should show the nearest product which match with query term.

query:
search?q=SEARCHTERM&query_by=name&filter_by=location:(LOCATION,RADIUS)&sort_by=location(LOCATION):asc

But the sorting is always show the nearest product first regardless of the match.
I tried setting num_typos=0. It works. but even a slight mistake omit the product from response

Is there any way to get the desired result?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:14 PM
Ramees Could you try this query:

search?q=SEARCHTERM&query_by=name&filter_by=location:(LOCATION,RADIUS)&sort_by=_text_match:desc,location(LOCATION):asc
Ramees
Photo of md5-ddfa968eca4266b70a36c83bdcdc7b94
Ramees
05:14 PM
ok
05:15
Ramees
05:15 PM
I will try and let you know shortly

1

05:18
Ramees
05:18 PM
Wow, It's working!
05:19
Ramees
05:19 PM
Thank you so much.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:19 PM
🙌
05:19
Jason
05:19 PM
Happy to help!
Ramees
Photo of md5-ddfa968eca4266b70a36c83bdcdc7b94
Ramees
05:19 PM
You are awesome

1