Search code examples
nebula-graphopencypher

How to i return only results in optional match in nebula graph where result in optional match


The example statement is as follows:

MATCH (v)-[:has]->(:acl)<-[:ace_acl]-(:ace)-[:ace_principal|:member_of*1..2]-(v4) 
WHERE id(v4) == 'user_0001' 
OPTIONAL MATCH (v)-[:member_of]->(root:repository_group) 
return DISTINCT v ,root

i want to return only those childs that id(root) == "root_id"

how can I add where to this statement?

in this documentation said:

MATCH (v)-[:has]->(:acl)<-[:ace_acl]-(:ace)-[:ace_principal|:member_of*1..2]-(v4) 
WHERE id(v4) == 'user_0001' 
OPTIONAL MATCH (v)-[:member_of]->(root:repository_group) 
WHERE id(root) == '0001'
return DISTINCT v ,root

error is:

SyntaxError: Where clause in optional match is not supported. near `WHERE id(root) == '0001''

i want to add WHERE id(root) == '0001'

to filter results that the root ID is '0001'

is this possible or not?

I have an idea to write this query with go and pipe

is this the only solution for me?


Solution

  • so this is not optional

    this convert to match query like this:

    MATCH (v)-[:has]->(:acl)<-[:ac_acl]-(:ace)-[:ace_principal|:member_of*1..2]-(v4) 
    WHERE id(v4) == "user_0001" 
    MATCH (v)-[:member_of]->(root:repository_group) 
    WHERE id(root) == "repo_group_0001"
    return DISTINCT v ,root
    

    this is worked for me

    this is nebula studio screen shot and return documents there

    optional match witout where

    match with where