Match the node on the basis of properties values

22 views
Skip to first unread message

kchan...@gmail.com

unread,
Feb 22, 2018, 12:20:15 PM2/22/18
to Neo4j

I have a large graph I need to find exact graph.
My match query is :
MATCH (u:SQL_Query)-[:FROM]->(c:from_SQL), (u)-[:SELECT]->(c2:select_SQL) ,(u)-[:WHERE]->(c3:where_SQL) ,(v:where_SQL)-[:HAS]->(c4:where_value_data)
WHERE (c.from_sql IN [' user_view_status_logs ']) AND (c2.select_query IN [' (1) AS a ']) AND (c3.select_query IN [' (user_view_status_logs.event_id = 86 AND user_view_status_logs.user_id = 35 AND user_view_status_logs.log_type = Program) LIMIT '])  AND (c4.where_value IN [' user_view_status_logs.user_id = 35 ',' user_view_status_logs.event_id = 86 ' ])
RETURN u

I got the graph it works given above in attachment():-

Issue:-
My issue is number of node connected is 3 but i ask for only 2 with value. IN function does not match exactly.


Michael Hunger

unread,
Feb 22, 2018, 12:28:34 PM2/22/18
to ne...@googlegroups.com
You only returned `u` so a single node
if you then double click that it expands all the connected data.

If you want to return your query results do `RETURN *`



--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kchan...@gmail.com

unread,
Feb 23, 2018, 1:27:47 AM2/23/18
to Neo4j


My concern is something different I am getting wrong graph on Match only I want that graph who only satisfy my condition not more than that like I want that graph who have only two node connected with where_SQL(Label) but I am getting three node connected to where_SQL Label.

Kamal Murthy

unread,
Feb 23, 2018, 1:43:08 PM2/23/18
to Neo4j

Hi,

I do not know your complete data model, but from your query I created a sample.

Here is my script:

CREATE (u:SQL_Query)
CREATE (c:from_SQL {from_sql: "user_view_status_logs"})
CREATE (u)-[:FROM]->(c)
CREATE (c2:select_SQL {select_query: "(1) AS a"})
CREATE (u)-[:SELECT]->(c2)
CREATE (c3:where_SQL {select_query: "(user_view_status_logs.event_id = 86 AND user_view_status_logs.user_id = 35 AND user_view_status_logs.log_type = Program) LIMIT"})
CREATE (u)-[:WHERE]->(c3)
CREATE (c4:where_value_data {user_view_status_logs_user_id: 35, user_view_status_logs_event_id: 88})
CREATE (c3)-[:HAS]->(c4)
CREATE (c5:where_value_data {user_view_status_logs_user_id: 35, user_view_status_logs_event_id: 86})
CREATE (c3)-[:HAS]->(c5)
CREATE (c6:where_value_data {user_view_status_logs_user_id: 33, user_view_status_logs_event_id: 87})
CREATE (c3)-[:HAS]->(c6); 

Here I have included 'user_view_status_logs_user_id' and 'user_view_status_logs_event_id' properties in the same  where_value_data node. You can have these properties in two different properties one in each where_value_data node. It should still work.

MATCH (u:SQL_Query)-[:FROM]->(c:from_SQL), (u)-[:SELECT]->(c2:select_SQL) ,(u)-[:WHERE]->(c3:where_SQL)-[:HAS]->(c4:where_value_data)
WHERE c4.user_view_status_logs_user_id = 35 AND
c4.user_view_status_logs_event_id= 86
RETURN u,c, c2, c3,c4;


MATCH (u:SQL_Query)-[:FROM]->(c:from_SQL), (u)-[:SELECT]->(c2:select_SQL) ,(u)-[:WHERE]->(c3:where_SQL)-[:HAS]->(c4:where_value_data)
WHERE c4.user_view_status_logs_user_id = 33 OR
c4.user_view_status_logs_event_id= 86
RETURN u,c, c2, c3,c4;


Hope this will help you.

-Kamal
Reply all
Reply to author
Forward
0 new messages