Algolia exception filters: Unexpected token string(to) expected ')'

2.1k views Asked by At

I am trying to perform filtering in my Android app using Algolia as they have shown in their Filtering and facets tutorial but I am getting this error in my query.setFilters() method: Algolia exception filters: Unexpected token string(to) expected ')'

Here is the code sample I used:

Query query = new Query();
query.setAttributesToHighlight("type");
query.setHighlightPreTag("<p style=\"color:red\">");
query.setHighlightPostTag("</p>");
query.setRestrictSearchableAttributes("type","price");
query.setFilters("code=1 AND (price:1000 to 300000000 OR price:10 to 100)");

My aim is to perform a range search on my data. How can i achieve that?

1

There are 1 answers

2
PLNech On BEST ANSWER

The code snippet in the tutorial had a typo, filter keywords should be in all caps as you can see in the Filter Syntax list of keywords.

You should use this instead:

query.setFilters("code=1 AND (price:1000 TO 300000000 OR price:10 TO 100)");