Searching user favorited documents

Hi @vortextangent ! Welcome to the Elastic community!

There are two approaches that could work for this case:

  • Up to 32,768 values can be specified in a query filter, when using filter arrays. You can have a look at this in the documentation:

Arrays vs. Objects

Be mindful of the 32 filters limit when building large filtered queries.

Instead of stacking objects, you can use an array when values share a field.

Each array can contain 1024 values.

If need be, you can use 32 full arrays to filter on a total of 32,768 values.

Array behaviour varies depending on whether you are using any , all , or none ...

  • You could add the user ID to each document that the user marks as favorite in a dedicated field. App Search supports array values in fields, so user IDs could be stored in each document and then perform filtering in this field for the specific user ID.

Given that you have millions of users, a proof of concept should be done to check the performance / usefulness of the last approach. This approach is described as well in this post.

Regarding multiple favorites lists, the name of the favorite list can be encoded as part of the user ID to add to the document, for example concatenating the list name or id with the user id.

Please share your findings with us!