Hi team! Maybe you know a better way to solve this...
# community-help
d
Hi team! Maybe you know a better way to solve this problem 🙌 Details in the thread.
I have dataset of documents and also hierarchy or users. For simplicity of reproducible example each user belongs to a team, and each team belongs to a department. Some of documents in my dataset have different visibility rules and I want to reproduce them in the search engine. For example: • Article with list of employees, available for the whole company • Article with internal department rules, available for
department1
(i.e. for all teams in this department) • Article with internal team’s drafts, available for
team1
My first idea was to use arrays for such visibility fields and then fullfill them with corresponding values. If visibility chosen as
department1
, we will add corresponding teams too. Solution looks like this Problems with this solution are: • Some people can be outside teams or departments. For example CEO or other leaders. • We need to update index every time when new teams are created, otherwise they will get empty results (e.g. newcomer team5 won’t get even publicly available documents)
j
Your examples sound very close to what is described here under Role Based Access Control: https://typesense.org/docs/0.24.0/api/api-keys.html#role-based-access
Some people can be outside teams or departments. For example CEO or other leaders.
You could add them to an internal admin “system” team of sorts, that is not exposed to your end users
We need to update index every time when new teams are created, otherwise they will get empty results (e.g. newcomer team5 won’t get even publicly available documents)
You could create another attribute called
is_public: true|false
in each document
d
And then run two searches and merge them back?
j
and then your filter can be:
Copy code
(departments:=[`department1`] && teams:=[`team1`]) || is_public:true
d
Do you support OR? 🌚
j
In the latest version 0.24.0 yes!
d
j
Yeah that would work too
d
Ah, it looks I have a logic error in my example, I will check it and return later. Thank you!
👍 1
Could you please check the latest gist? I got only
"available for all"
document, but expected
"available for department1 (so for all nested teams)"
too, because
departments
contains
department1
🤔
j
Could you confirm you’re using v0.24.?
d
0.24.0.rcn56. Let me update it to the latest one
Sorry, my bad. Had outdated docker build
😅 1
Now it’s working as it should be! Thank you for the OR, it’s lifesaving
😄 1
🙌 1