Chaining filters together

Is there a way to chain filters together in Algolia?

const weight = 100;
const eyes = ‘blue’
const height = 110;

instead of writing:
const filterString = weight: ${weight} AND eyes: ${eyes} AND height: ${height}
This could get very cumbersome if you had 100 filter attributes, each of which may or may not be included in the string.

I know firebase/firestore is a different product but they accomplish chaining like so:

let query = firebase.firestore().collection(“person”)
if (weight) {
query = query.where(“weight”, “==”, weight)
if (eyes) {
query = query.where(“eyes”, “==”, eyes)
if (height) {
query = query.where(“height”, “==”, height)

Hi @steviebey123,

We do not have this kind of methods for chaining filters that you shared.

The syntax you shared for filtering in Algolia is correct, you can also find all the different syntax variations here: We do not have any specific method to chain filters, but you can just programmatically concatenate the strings before sending them along with your query.

You can find a full guide on filtering here:

Sounds good, thank you for the response, i will go about it that way. I just wanted to be sure I was not passing over a feature. :+1:

1 Like