我的Neo4j實例中填充了本地大學的完整校友數據集。 (248K)節點(n:校友)中的一小部分(15K)包含一個twitter user_name。我的目標是使用加載並鏈接twitter screenNames以獲取關係數據的GITHUB應用程序(TWIITER至NEO4J)。我的問題是,下面的查詢(它包含在GITHUB應用程序的java腳本中)Cypher創建了不符合Alumni screen_name的不需要的Follower/Follow節點。我想寫一個查詢,只允許從應用程序創建關係。讓我知道這是不是更清晰....需要匹配而不是MERGE
MERGE (targetNode:Person {screen_name: {screenName}})
FOREACH (friend in {userList} |
MERGE (friendNode:Person {screen_name: friend.screen_name})
ON CREATE SET friendNode=friend
MERGE (targetNode)-[:FOLLOWS]->(friendNode))
這是我的想法 - 我設置的MERGE相匹配校友
MATCH (targetNode:Alumni {screen_name: {screenName}})
WHERE targetNode:Alumni.screen_name = {screen_name}
FOREACH (friend in {userList} |
MATCH (friendNode:Alumni {screen_name: friend.screen_name})
SET friendNode=friend
MERGE (targetNode)-[:FOLLOWS]->(friendNode))
感謝您的任何想法...
var multiline = require('multiline');
exports.upsertOne = multiline(function(){/*
MERGE (n:Person {screen_name: {screenName}})
ON CREATE SET n+={userMap}
RETURN n
*/});
/*
* Parameters are:
*
* screenName - string, the handle of the person to attach followers to
* userList - array of objects, people to merge and create relationships
*/
exports.upsertManyAndFollows = multiline(function() {/*
MATCH (followeeNode:Alumni {screen_name: {screenName}})
UNWIND {userList} as follower
MATCH (followerNode:Alumni {screen_name: follower.screen_name})
SET followerNode=follower
MERGE (followerNode)-[:FOLLOWS]->(followeeNode)
*/});
/*
* Parameters are:
*
* screenName - string, the handle of the person to attach followers to
* userList - array of objects, people to merge and create relationships
*/
exports.upsertManyAndFriends = multiline(function() {/*
MATCH (targetNode:Person {screen_name: {screenName}})
UNWIND {userList} as friend
MATCH (friendNode:Person {screen_name: friend.screen_name})
SET friendNode=friend
MERGE (targetNode)-[:FOLLOWS]->(friendNode)
*/});
/*
* Parameters are:
*
* screenName - string, the handle of the person that is at the center of the graph.
*
*/
你還沒有明確你遇到什麼問題以及你需要什麼幫助。請在結束前澄清您的描述。 – InverseFalcon
有一點需要注意,儘管...你說你創建了:應用程序另一部分中的人員節點,但是您使用的是:最後一個查詢中的校友節點。確保你使用相同的標籤。 – InverseFalcon
請讓我知道如果這有幫助 - 它不會我再試一次... – INNOSOLjim