useRefinementList not working as expected on a geopoint field
iamarora opened this issue · comments
Description
The refine method on a geopoint field is giving an error.
Steps to reproduce
const { refine } = useRefinementList({ attribute: 'location_geo' });
// Tried the below
refine('(-44.50, 170.29, 20 mi)')
Expected Behavior
It should be able to refine results with lat, long and radius.
Actual Behavior
The error is
Error: 400 - Value of filter field location_geo: must be in the ([-44.50, 170.29], radius: 0.75 km, exact_filter_radius: 5 km) or ([56.33, -65.97, 23.82, -127.82], exact_filter_radius: 7 km) format.
Metadata
Typesense Version: 0.26.0.rc25
OS: Ubuntu
Ref: https://typesense-community.slack.com/archives/C01P749MET0/p1698234116317759
Generated query:
curl 'http://0.0.0.0:8108/multi_search?use_cache=true&x-typesense-api-key\
-H 'Accept: application/json, text/plain, */*' \
-H 'Accept-Language: en-US,en-IN;q=0.9,en;q=0.8' \
-H 'Connection: keep-alive' \
-H 'Content-Type: text/plain' \
-H 'Origin: http://localhost:3010/' \
-H 'Referer: http://localhost:3010/' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
--data-raw '{"searches":[{"query_by":"full_name","min_len_2typo":8,"split_join_tokens":"fallback","sort_by":"update_time:asc","per_page":40,"highlight_full_fields":"full_name","collection":"people_index","q":"*","facet_by":"location_city_geo_map,location_geo,org_funding_types_all,org_funding_types_current,org_industries_current,org_industry_groups_current,org_sizes_current","filter_by":"location_geo:=[`(56.33, -65.97, 20 mi)`]","max_facet_values":40,"page":1},{"query_by":"full_name","min_len_2typo":8,"split_join_tokens":"fallback","sort_by":"update_time:asc","per_page":40,"highlight_full_fields":"full_name","collection":"people_index","q":"*","facet_by":"location_geo","max_facet_values":40,"page":1}]}' \
--compressed \
--insecure
This is the problematic part:
"filter_by": "location_geo:=[`(56.33, -65.97, 20 mi)`]"
It should have been:
"filter_by": "location_geo:=(56.33, -65.97, 20 mi)"
Hi! any eta on this issue?
Hi! any eta on this issue?
Hey, I ended up using this to get my use case working. Doesn't look like refinement lists work with geopoint fields.
Hi! any eta on this issue?
Hey, I ended up using this to get my use case working. Doesn't look like refinement lists work with geopoint fields.
Thank you very much.
I use this temporary solution for now:
const finalLocation = location ? location : undefined;
const finalRadius = finalLocation ? radius * 1000 : undefined;
<InstantSearch searchClient={searchClient} indexName={'candidats'}>
<Configure
aroundLatLng={finalLocation}
aroundRadius={finalRadius}
/>
finalLocation: 45.5764258, -73.5466107
finalRadius: 75000
Hi! any eta on this issue?
Hey, I ended up using this to get my use case working. Doesn't look like refinement lists work with geopoint fields.
Thank you very much.
I use this temporary solution for now:
const finalLocation = location ? location : undefined;
const finalRadius = finalLocation ? radius * 1000 : undefined;
<InstantSearch searchClient={searchClient} indexName={'candidats'}> <Configure aroundLatLng={finalLocation} aroundRadius={finalRadius} />
finalLocation: 45.5764258, -73.5466107 finalRadius: 75000
Yeah, I had tried the configure widget as well. That's good to apply the initial filter, but when the values change dynamically from the FE it wasn't filtering then, but the initial filter was working well with the Configure widget.
location and radius are states so it's working when i change values dynamically. But it's rendering everytime!