algolia/algoliasearch-client-android

setAroundRadius() only accepts integers

condesales opened this issue ยท 5 comments

I'm trying to search by location using Lat, Lng but I don't want the results to be filtered by the automaticRadius stuff.

Here's what I've tried so far:

  • setAroundRadius() from the sdk only accepts integers, I cannot set the "all" argument described at the documentation
  • setting aroundRadius=all using the setFilters() method but it doesn't seems to work.
  • use the browse interface to replicate my android query, but the add query parameter stuff don't allow me to set the Radius to "all" either, just integers ๐Ÿ˜ž

Using a massive Integer and setting using setAroundRadius() would probably solve the problem, but docs say performance is not the best.

Not sure if it's a limitation from the API or if I'm doing something wrong on my end.

Hello @condesales, sorry for this issue!

Good catch, the current setAroundRadius() does not support setting aroundRadius to "all"!
I'll implement this and will let you know when it is released.

In the meantime, we provide a low-level setter for parameters that are not yet (or not fully) implemented: Query.set() with which you can set any parameter. (The setFilters() method you used, however, is related to the filters parameter.)

Try query.set("aroundRadius", "all") and let me know if this workaround lets you search by location! I'll update this ticket as soon as we release an updated setAroundRadius ๐Ÿ™‚

Aha. Nice one!
I gave it a try and I can confirm that query.set("aroundRadius", "all") works and I get the expected results now ๐Ÿ˜

@condesales: I'm glad to hear that! ๐Ÿ™‚

However I was wrong on one thing: we already handle the "all" case using the Query.RADIUS_ALL constant! You can replace set("aroundRadius", "all") by setAroundRadius(Query.RADIUS_ALL), which will be more future-proof ๐Ÿ˜„

public static final int RADIUS_ALL = 2147483647; wouldn't that cause the performance issue described in the docs?

It would if we did send it as-is, but see the setAroundRadius implementation:

 if (radius == Query.RADIUS_ALL) {
            return set(KEY_AROUND_RADIUS, "all");
 }