Working with currency

Hello,
I’m using Algolia REST API with my app builder and I’ve indexed about 22k products. There price is added like this from the DB that I get the data from:
Skjermbilde 2020-05-19 kl. 10.15.51

The price is always in NOK, written like this: “50kr” or “50 kr”
What I’m trying to do it help the user make a search like: “I want a RED WINE for 100KR” So here i want to retrieve red wines around 100kr. It needs to be around 100kr, maybe off +/- 50kr, so it’s more flexible.
I can easily do this with stop-words for the wine type, but I can’t make it work with the currency. How would I solve this?

Hello Alexander, you can achieve this by using Algolia’s numeric filtering option, we have a complete guide in our documentation that you can reference. You can use the price <= upperBound to get anything that is in the 10% of the upper bound and use the same filter for a lower bound. Let us know if that works for you :)!

1 Like

But what would I do with the “kr” part and how would this help the user just typing it into the search bar without having to choose the filter themself? :slight_smile:

Indeed, the value indexed would need to be of numeric type. I would suggest that once you render the results, you would just append the “kr” at the end of the string as it’s otherwise impossible to properly apply numeric operators to string values anyways.

What you are referencing in your second part is “I want a RED WINE for 100KR” is a conversation based approach which is mostly present in voice applications, but requires some post-processing of the query, extracting entities and applying those to the search engine. Today Algolia does not provide such a feature, so you would need to implement it on your own. I’m looping in a colleague of mine (@dustin ) who works on that part of our product, he’ll be able to give you a better answer.

Ah, ok :slight_smile: Thank you! I’ve been able to make the search except the 100KR part, maybe I will just leave it then.

Hi Alexander, are you looking just at slices? For example, 50, 100, 150, 200? If that’s the case, I would recommend creating different rules for each, and returning json with the value.

This is something that we’ve looked at to see how we can make it easier. Nothing to announce right now, but it’s on our mind.