How to set search attribute in firebase child data with unique keys?

Hello everyone. I am using firebase as the database. I have indexed the data on firebase. My data structure is like in the image.

I am trying to set search attribute on root from algolia dashboard. How can I do that? Thank you already.

Thanks for posting your question @tummyapplication.

You will need to use a different structure for your Algolia data than the Firebase data. Specifically, you cannot have dynamically generated IDs in the path to the indexable attribute. Instead, you can index the data in Algolia as arrays of objects, and store the menu item ID and menu ID of each object as attributes in each object.

The JSON you send to Algolia would look something like this:

menu_items: [{
  id: "KcZ...Hcu",
  menuId: "KcZ...ekR",
  name: "Beyaz..."

With that structure, you would configure to be in searchableAttributes.

Thank you for your great answer. I have done some changes and set the firebase key as id attribute and index with an array. It work perfectly. Thank you

1 Like