Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-02-2020 01:42 AM
Hi, I need to find all the files directly shared with the user or via a group created by someone else.
I tried the following query it is giving results, however, if no file has been shared directly with the user or via group then I see three nodes with no relation
it might be possible the same file is shared directly to the user and with the group and the user is part of that group too. In this case, I need a file which is directly shared with the user not the group one.
I have also attached the dump for our database
https://wetransfer.com/downloads/6cc18b36e9f682aeeed8244d8b36719520200102081814/57ac4525bca19391b7e7...
match (u:user) where u.ohrid = "120"
match (f:file)
optional match (u)-[mg:MEMBER_OF_GROUP|CREATED_GROUP]->(g:group)<-[fswg:FILE_SHARED_WITH_GROUP]-(f)
optional match (f)-[fsw:FILE_SHARED_WITH]->(u)
return u, mg,fswg, g, fsw, f
Thanks
Meet
01-02-2020 03:06 PM
There's probably a few ways to solve this, one approach could be to use the shortestPath function, which will collect files according to the relationship predicate you specify (docs @ https://neo4j.com/docs/cypher-manual/current/clauses/match/#query-shortest-path)
match (u:user{ohrid:"127"}), (f:file), p = shortestPath((u)-[:FILE_SHARED_WITH|:FILE_SHARED_WITH_GROUP|:MEMBER_OF_GROUP*..2]-(f))
return u, p, f
Note I ran this for user "127", as "120" does not seem to have any files connected in your sample graph, and their only group "Reader" doesn't have any either.
01-03-2020 04:20 AM
Thanks, terry really appreciate, this query works. I have some permission data at a group level and file level. How can I check?
In relation to the user to a group (:MEMBER_OF_GROUP). We have some permission for the user which will be checked for the group and (:FILE_SHARED_WITH_GROUP) shared file with that group.
in relation FILE_SHARED_WITH we have some permission on file for that user.
if i get same file from both path then i will consider [:FILE_SHARE_WITH] relation as permssion for file else :MEMBER_OF_GROUP
Please let me know how can I achieve this.
Regards
Meet
01-03-2020 08:09 PM
Can you provide cypher statements to generate sample data? Will be easier to reason about.
01-04-2020 06:48 AM
Hi Terry,
Below is the whole sample database cypher queries. Looking forward to hearing from you.
Regards
Meet
01-04-2020 08:11 PM
I have a local copy of your graph setup but I'm still not sure I understand the problem you're trying to solve.
Can you try rephrasing it, perhaps as example questions to ask of the data you've provided?
01-04-2020 09:32 PM
Let's say user (Surabhi Misra). She is a [MEMBER_OF_GROUP] named (Tech) group. In this relation, we are storing group level permission for that user. There is a file (A8 Manual) which is shared with a (Tech) group node by another user named (Manish Kumar) node. (Surabhi Misra) is part of that group. She can access that file with group-level permission. She can only perform the task on that file based on that group's permission.
now someone else / same person shared the same file directly to that (Surabhi Misra). Then file level permission has higher precedence than the group level permission. We are creating a direct relation for the file to that user and keeping file level permission in a relationship (file)-(FILE_SHARED_WITH)->(user)
now I want to see all the file user has CREATED_FILE, FILE_SHARED_WITH, FILE_SHARED_WITH_GROUP by him/her, shared with him/her. if the same file has been shared via group and directly then I need the direct file, not the file shared with the group.
if no file created or shared by the user then the result should be empty.
01-05-2020 01:51 PM
So you need to confirm that the relationship path between a file and user (direct if available, otherwise via a group) contains a certain permission?
match (u:user{ohrid:8504}), (f:file), p = shortestPath((u)-[rels:FILE_SHARED_WITH|:FILE_SHARED_WITH_GROUP|:MEMBER_OF_GROUP*..2]-(f))
where any (rel in rels where 'read' in rel.documentPermission)
return u, p, f
Does this give you the result you're looking for?
All the sessions of the conference are now available online