Hi, I'm quite confused here.. And I'm sure it is me not understanding something, but when I use this query
neo4j@neo4j> MATCH (s:source) where s.url = 'Yahoo News - Latest News & Headlines' CREATE (k:keyword {keyword:'TEST'}), (k) - [:KEYWORD_ADDED_BY] -> (s) RETURN k.keyword as keyword;
+---------+
| keyword |
+---------+
| "TEST" |
+---------+
1 row
ready to start consuming query after 0 ms, results consumed after another 1 ms
Added 1 nodes, Created 1 relationships, Set 1 properties, Added 1 labels
Everything seems to be as I would expect..
however, if I do this query,
neo4j@neo4j> match (a) - [r:KEYWORD_ADDED_BY] - (b) return a,r,b;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| a | r | b |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| (:keyword {keyword: "TEST"}) | [:KEYWORD_ADDED_BY] | (:source {name: "Yahoo News - Latest News & Headlines", url: "Yahoo News - Latest News & Headlines", organizaion: "Copyright (c) 2022 Yahoo! Inc. All rights reserved"}) |
| (:source {name: "Yahoo News - Latest News & Headlines", url: "Yahoo News - Latest News & Headlines", organizaion: "Copyright (c) 2022 Yahoo! Inc. All rights reserved"}) | [:KEYWORD_ADDED_BY] | (:keyword {keyword: "TEST"}) |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows
ready to start consuming query after 1 ms, results consumed after another 0 ms
It seems to have the relationship in both directions, which is wrong..
And I can do a query with the direction arrows, and they will both show up
neo4j@neo4j> match (a) - [r:KEYWORD_ADDED_BY] -> (b) return a,r,b;
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| a | r | b |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| (:keyword {keyword: "TEST"}) | [:KEYWORD_ADDED_BY] | (:source {name: "Yahoo News - Latest News & Headlines", url: "Yahoo News - Latest News & Headlines", organizaion: "Copyright (c) 2022 Yahoo! Inc. All rights reserved"}) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row
ready to start consuming query after 12 ms, results consumed after another 0 ms
neo4j@neo4j> match (a) <- [r:KEYWORD_ADDED_BY] - (b) return a,r,b;
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| a | r | b |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| (:source {name: "Yahoo News - Latest News & Headlines", url: "Yahoo News - Latest News & Headlines", organizaion: "Copyright (c) 2022 Yahoo! Inc. All rights reserved"}) | [:KEYWORD_ADDED_BY] | (:keyword {keyword: "TEST"}) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row
ready to start consuming query after 9 ms, results consumed after another 1 ms
that second query should not respond like that, or at least I don't want it to do so.. I want the relationship in one direction only.. What did I do wrong with my initial match/create statement?
Thanks for the help as I'm lost on this one.. Previously I always created the node on one statement, and then the relationship on a separate statement.. And it works as expected (only a directional relationship is created).. I tried now to combine both operations into a single query and obviously I screwed up somewhere, I just don't know where..
- Andre