Too many relationships being returned

Disclaimer: I'm a beginner to neo4j. I've walked through the tutorial. I've built my data, and loaded it into a graphdb and I'm trying to validate that it imported correctly.

I'm not sure if the problem I'm having is something I'm doing in the import or in the cypher query.

I'm using this import tool to import the following files (the below has been filtered to just contain the rows I'm currently investigating):

application_id node file:

application_id:ID(application_id),:LABEL
2036983247,application_id
2037028183,application_id

personal_phone node file:

personal_phone:ID(personal_phone),:LABEL    
5555551234,personal_phone

relationship file:

:START_ID(personal_phone),:END_ID(application_id),:TYPE
5555551234,2036983247,APPLIED
5555551234,2037028183,APPLIED

My cypher query:

match p= (a {personal_phone:'5555551234'}) -->(b) return p

In my results I see that the personal_phone node has 2 'APPLIED' relationships with each of the application_id nodes. I'd expect to see only one. Where am I going wrong?

EDIT : This is what I see. The center node is the personal_phone node.

EDIT 2 : So I figured out that using the dump statement from the neo4j shell I could get an export of the database. I figured I'd run it for the nodes in question:

$ dump match p= (a personal_phone:'5555551234'})-->(b) return p;

Returns:

begin
create (_5:`application_id` {`application_id`:"2036983247"})
create (_410:`application_id` {`application_id`:"2037028183"})
create (_6928:`personal_phone` {`personal_phone`:"5555551234"})
create _6928-[:`APPLIED`]->_410
create _6928-[:`APPLIED`]->_5
create _6928-[:`APPLIED`]->_410
create _6928-[:`APPLIED`]->_5
;
commit

This shows that I definitely have duplicate relationships. Any ideas on how I can fix this?


You add two APPLIED relationships from a single personal_phone node to two different application_id nodes.

When you MATCH all relationships from this personal_phone node, you would indeed expect to get two APPLIED relationships as result.


Ugh - dumb mistake in my import was the issue. It went unnoticed because there were soo many different files being imported but basically I had the relationships file importing twice in my script file:

--relationships "f:tempr_personal_phone_application_id_APPLIED.csv" 
--relationships "f:tempr_personal_phone_application_id_APPLIED.csv" 
链接地址: http://www.djcxy.com/p/27302.html

上一篇: 如何检查一个对象是否在JavaScript中有键?

下一篇: 返回的关系太多