Reputation: 43
I am building an application where I need to display documents based on multiple conditions related to visibility and user relationships. Here’s the logic I want to implement:
I initially tried to implement this directly using Firestore, but ran into limitations with full-text search and Firestore’s inability to evaluate follower relationships dynamically within security rules.
What I've Tried with Algolia:
I switched to using Algolia to handle this, and I set up the filters as follows:
filters: 'visibility:"public" OR createdBy:"currentUserId" OR (visibility:"followers" AND (createdBy:"followingUserId"))'
However, this results in the error:
ApiError: filters: filter (X AND Y) OR Z is not allowed, only (X OR Y) AND Z is allowed
My Question:
Is there a way to structure these filters correctly in Algolia to achieve the desired behavior given the limitation
(X AND Y) OR Z is not allowed, only (X OR Y) AND Z is allowed
?
If this approach is not suitable, what is the recommended method for handling this type of visibility filtering in a scalable and efficient manner using Algolia or any other approach compatible with Firestore?
Any guidance or best practices would be greatly appreciated. Thank you!
Upvotes: 1
Views: 52