How to do a comparison filter with two properties of a record?

I have two properties on my record: Price and OriginalPrice I’d like to retrieve a list of discounted prices by filtering all records where Price < OriginalPrice.

I tried using a numeric filter but of it seems only one of the parts can be a record you are comparing against and the other part must be a number.

Hi @cramirez,

Thanks for contacting Algolia. You’re on the money - as described here, the syntax for filters is:

'numeric_attribute = | != | > | >= | < | <= numeric_value'

So in the filters parameter itself you would not be able to compare your “Price” and “OriginalPrice” against each other.

What you can do is calculate this beforehand and consider adding a third attribute called “isDiscounted” and set it to “true” or “false” for each Algolia record.

Then you can filter on the boolean - booleans are treated as numbers; true = 1 and false = 0:


@ajay.david thank you for the prompt response. Sounds good, we will solve using your suggested method.