algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 222 forks source link

URL-encoded facet filters #1474

Closed woudsma closed 1 year ago

woudsma commented 1 year ago

Should I use encodeURIComponent on the filters that are sent with the viewedFilters event?

The docs mention this:

Format: ${attribute}:${value}—for example, brand:apple. Each facet filter string must be URL-encoded, such as, "discount:10%25".

The example confuses me, since encodeURIComponent('discount:10%') becomes discount%3A10%25, not discount:10%25. Can I assume that this is an error in the docs?

Haroenv commented 1 year ago

The facet and its value should be encoded separately, not the entire string, maybe the wording in the docs could be improved to show that (Each facet and its value must instead of Each facet filter string must maybe)

woudsma commented 1 year ago

@Haroenv Thanks for your quick reply! That wasn't clear for me from reading the docs, thanks for your explanation.

I'd suggest something like this:

Both the attribute and value in each facet filter must be URL-encoded and separated by a :, such as, "discount:10%25".

Please feel free to close this issue!

Haroenv commented 1 year ago

I've updated the docs with your clarification, thanks!