Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding Neo4j, creating unique nodes
    primarykey
    data
    text
    <p>I'm trying to wrap my head around how Neo4j works and how I can apply it to my problem. I thought it should be really easy and a matter of minutes, but I'm stuck.</p> <p>I have data in MongoDB, say <code>User</code> and <code>Item</code>. What I want is connecting <code>User</code> and <code>Item</code> in a graph with a <code>LIKE</code> relationship (maybe with a <code>score</code>). Later I want to do things like recommending items based on connections, basic stuff.</p> <p>But how do I get the data into Neo4j? Every document in MongoDB has an unique <code>_id</code>, so I though I could just throw both <code>_id</code>s into Neo4j and have them connected. What I found so far is that it's not even possible to have unique nodes based on the <code>_id</code> field (Neo4j has numeric incremented ids), which is only possible with some "hack" (<a href="https://github.com/jexp/app-net-graph/blob/master/lib/appnet.rb#L11" rel="nofollow">https://github.com/jexp/app-net-graph/blob/master/lib/appnet.rb#L11</a>) or using <code>MERGE</code> (I'm stuck on &lt; 2.0). Even their examples on the website add the same node again if executed multiple times. I think I have a fundamental misunderstanding of how to use Neo4j. Maybe I'm too spoiled by redis, where I can put strings in and and <em>it just works</em>. Redis' sets aren't feasible though for complex graphs, only for simple connections.</p> <p>Maybe someone can help me with a simple cypher example of how to add two nodes <code>foo</code> and <code>bar</code> and have them connected with a <code>LIKE</code> connection. And the operation should be idempotent, no matter if none or all of the nodes/relationships already existed before execution.</p> <p>I'm accessing Neo4j via REST, in particular using this node module <a href="https://github.com/thingdom/node-neo4j" rel="nofollow">https://github.com/thingdom/node-neo4j</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload