Hi folks, I have a collection of items rated by di...
# community-help
m
Hi folks, I have a collection of items rated by different users on multiple criteria (novelty, writing, etc.). Reviewers have an id and each item is reviewed by a dynamic number of users (at most ~20-30). Is there a canonical way to solve this problem? I.d. like to be able to make queries like: give me the stuff that Jane Doe (with e.g. id1) has rated 4 or higher on writing.
s
Have you read through the JOIN area of the documentation? https://typesense.org/docs/27.1/api/joins.html#many-to-many-relation I had a similar problem but with different data, and determined I needed to use a joined collection. I was first trying to use a flattening approach like this but found that caused my schema to be bespoke. And same for you; you wouldn't want a schema node for every user, since your user base is always growing/changing. Using a joined collection was the answer for me. I am still waiting for v.28 to be able to search on fields in joined collections. But if you just need to filter with concrete criteria, I think the existing join approach would work.
f
Apart from joins, you could save a field called
available_to
with a string array of the IDs of users that it's available to. Basically Joining without the link collection itself
m
I’m doing the flattening right now, since the number of reviewers is fixed, but JOINs may be the right way to go, I’ll look closer at that. Thanks for the help!
since the [total] number of reviewers is fixed