Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-13-2019 10:33 AM
I would like to do a query like this:
match (n:Node{cat:'rel'})-[:REL{rel:'body'}]->(n2:Node)
match (n2{cat:'ssub'})
or (n2{cat:'conj'})-[:REL{rel:'cnj'}]->(:Node{cat:'ssub'})
or (n2{cat:'du'})-[:REL]->(:Node{cat:'ssub'})
return n;
But you can't use or
.
What else can I do?
Solved! Go to Solution.
11-14-2019 04:07 AM
11-13-2019 12:57 PM
its not really clear what you are looking to do.
You can include a or
in a WHERE
clause. Do you want to do
match (n2{cat:'ssub'})
where
(n2{cat:'conj'})-[:REL{rel:'cnj'}]->(:Node{cat:'ssub'})
or (n2{cat:'du'})-[:REL]->(:Node{cat:'ssub'})
or are you also looking for an OPTIONAL MATCH
??
11-13-2019 02:25 PM
With where
it looks like this:
match (n:Node{cat:'rel'})-[:REL{rel:'body'}]->(n2:Node)
where
(n2{cat:'ssub'})
or (n2{cat:'conj'})-[:REL{rel:'cnj'}]->(:Node{cat:'ssub'})
or (n2{cat:'du'})-[:REL]->(:Node{cat:'ssub'})
return n;
This generates an error:
Neo.ClientError.Statement.SyntaxError: Type mismatch: expected Boolean but was Map (line 3, column 6 (offset: 67))
" (n2{cat:'ssub'}) "
^
11-13-2019 02:50 PM
This works...
match (n:Node{cat:'rel'})-[:REL{rel:'body'}]->(n1:Node)
where (n1{cat:'ssub'}) is not null
or (n1{cat:'conj'})-[:REL{rel:'cnj'}]->(:Node{cat:'ssub'}) is not null
or (n1{cat:'du'})-[:REL]->(:Node{cat:'ssub'}) is not null
return distinct n.sentid as sentid, n.id as id, n1.cat
order by sentid, id;
But I get some results where n1.cat
is neither ssub
nor conj
nor du
, so these are clearly wrong.
11-14-2019 03:14 AM
change the
where
(n2{cat:'ssub'})
to
where
n2.cat='ssub'
11-14-2019 04:07 AM
That works. The results are correct.
All the sessions of the conference are now available online