Jésus Husbands
 · Co Founder at Melior

Searching through an array of document references using Algolia

Hey everyone, I’d love some help with something.

I’m trying to optimise search in my app using alogolia. I have a collection called “Restaurants” and i’ve made 2 attributes within this collection searchable, “restaurant_name” and “restaurant_categories”.

Restaurant Categories is an array of document references from a collection I have called “Categories”.

Within categories I have a field called “category_name”.

The search works perfectly if I search for a restaurant name. However, when I try to search for a restaurant by category, it works if I enter the ID of the category into the search field. Which makes sense because that’s what algolia has access too.

But I would like to know if there was a way for me to unpack the restaurant_categories in the search so that I would be able to search for a category name and get restaurants with the restaurant category that matches. I would love if anyone could help me out with this.

I’m thinking of just making all the category documents id the name of the category since categories are not user generated.

4 replies