RaviS
RaviS

Reputation: 13

Neo4jShell Facebook data import, cannot create relationships

I followed the following post to test facebook friends of friends in Neo4j 2.0.1 http://blog.neo4j.org/2013/06/fun-with-facebook-in-neo4j_19.html

I am able to create the nodes successfully.. Auto Indexing is enabled Here is the create node statement - create (n{name:'User 123', type:'Facebook'}); This works fine When I create the relationships, I am getting this notification: "Nothing was created and No data Returned"

Here is the create Relationship statement

start n1=node:node_auto_index(name='User 123'),n2=node:node_auto_index(name='User XYZ') CREATE n1-[:IS_A_FRIEND_OF]->n2;

Any help is very much appreciated. I am new to neo4j and trying to get my hands dirty by learning some stuff.

Upvotes: 1

Views: 79

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

Neo4j 2.0 has a new feature called schema indexes. For most use cases it's beneficial to use schema indexing instead of autoindexing.

For your example, I'd move the value of the type property to become a label.

First, create the index for property name based on label Facebook:

CREATE INDEX ON :Facebook(name)

The CREATE looks like:

CREATE (n:Facebook {name:'User 123'})

For creating the relationships use:

MATCH (n1:Facebook {name:'User 123'}),n2=(n2:Facebook {name:'User XYZ'}) 
CREATE n1-[:IS_A_FRIEND_OF]->n2

You might also look into Neo4j 2.0's new MERGE statement.

Upvotes: 1

Related Questions