After reading Algolia's Geo-search on steroid blog post I've implemented and OR filter using insidePolygon function and everything was working fine. But after a couple of days it started to return zero results.
From what I was able to verify this happens after setting the 2nd polygon.
I've checked all lat/lng tuples from the results that match, the string of lat/lng for the polygons values, and all seems fine to me.
When I set insidePolygon with the first polygon the results returned are correct. But if I set the 2nd polygon, Algolia returns zero results.
Here's what I'm doing. First polygon:
setQueryParameter("insidePolygon", "51.565237,-0.127758,51.548264,-0.061937,51.507314,-0.034756,51.466401,-0.062055,51.449465,-0.127758,51.466401,-0.193462,51.507314,-0.220760,51.548264,-0.193580");
This returns 22 results. All good.
Second polygon:
setQueryParameter("insidePolygon", "0.089927,0.000000,0.063588,0.063588,0.000000,0.089927,-0.063588,0.063588,-0.089927,0.000000,-0.063588,-0.063588,-0.000000,-0.089927,0.063588,-0.063588");
Now I have 0 results. Since this is an OR operator I find this behaviour really weird. It should at least show the 22 results I got from filtering with the first polygon.
Any help would be much appreciated.
Thanks!
Unless I did not understand your question correctly, your second call to
setQueryParameter
is actually overriding the first polygon you had set.My guess is that the second polygon doesn't contain any results, and so once you set it you end up with no hits.
To make an union of multiple polygons, you can use this syntax:
setQueryParameter("insidePolygon", [[...polygon1's points...], [...polygon2's points...]])
Which in your case would be:
You can of course have more than 2 polygons.