How to filter something using predicates in Neo4j?

I have first query like:

MATCH (U:User)-[S:Has|Shout]->(P:Post)
WHERE U.user_id=1
RETURN U.username, P.post

Query above will return all result from user_id=1 like:

U.username  P.post
rioeduardo  tomorrow
rioeduardo  hurray
rioeduardo  lala
rioeduardo  hey
rioeduardo  nice
rioeduardo  testing

And I have second query like:

MATCH (U:User)-[S:Shout]->(P:Post)<-[:Has]-(FU:User)
WHERE U.user_id=1
RETURN U.username, P.post

Query above will return all result from user_id=1 and others user also have it:

U.username  P.post
rioeduardo  tomorrow
rioeduardo  hurray
rioeduardo  lala
rioeduardo  hey

nah, I want to remove the result from user_id=1 and others user also have it, so the result will be:

U.username  P.post
rioeduardo  nice
rioeduardo  testing

I already tried using predicates in Neo4j but I got nothing. The query is like:

MATCH (U:User)-[S:Has|Shout]->(P:Post), filter=(U:User)-[:Shout]->(P:Post)<-[:Has]-(FU:User)
WHERE U.user_id=1 AND NONE (x IN nodes(filter) WHERE x.user_id = 1)
RETURN U.username, P.post

So, please help me how to solve this, if you have another way, just let me know(It doesn't have to be predicates.) Thanks.

Answers


Try below

MATCH (U:User)-[S:Has|Shout]->(P:Post)
WHERE U.user_id=1 AND NOT (U:User)-[:Shout]->(P:Post)<-[:Has]-(:User)
RETURN U.username, P.post

Need Your Help

Form built from database array values is not limiting radio buttons to single selection

php mysql radio-button radiobuttonlist

I am trying to build a form where the user selects an item based upon an array of values from a database table. Here is the code that I am using to filter out the list: