How to search to match an item inside of an array property of an index

Greetings!

I have to retrieve a list of users that consumes an app with a particular ID:

const users = algoliaClient.initIndex('users')
return users.search('myId123', { hitsPerPage: 50 });

But the users objects are just like this:

{apps: [
    {id: 'myId123'},
    {id: 'anotherId456'},
    {id: 'anotherId789'},
]}

How can I search the index for items with an apps property that contains an object with such Id?

@diaz.ailan.gonzalo welcome to the community!

For your example, if you add apps.id to the Searchable Attributes configuration for your Index, it should mark those fields as searchable.

For example:

1 Like