未创建关系,由Id匹配不返回结果

时间:2017-03-31 13:11:40

标签: neo4j

我刚刚开始使用Neo4j。

我正在尝试从CSV执行复杂的LOAD,但我似乎没有让关系部分正确。

LOAD CSV WITH HEADERS FROM "file:/Users/brestrepo/Krossover/neo4j/access_control_games.csv" AS csvLine
MERGE (game:Game
    {
        id: toInt(csvLine.id),
        datePlayed: csvLine.date_played,
        type: csvLine.type,
        createdAt: csvLine.created_at,
        updatedAt: csvLine.updated_at
    }
)
FOREACH(ignoreMe IN CASE WHEN trim(csvLine.deleted_at) <> "" THEN [1] ELSE [] END | SET game.deletedAt = csvLine.deleted_at)
WITH csvLine, game
MATCH (team:TEAM { id: toInt(csvLine.created_by_team_id)}),(game:Game { id: toInt(csvLine.id)})
CREATE (team)-[:OWNER_TEAM { }]->(game)
WITH csvLine, game
MATCH (user:User { id: toInt(csvLine.created_by_user_id)}),(game:Game { id: toInt(csvLine.id)})
CREATE (user)-[:OWNER_USER { }]->(game)
WITH csvLine, game
MATCH (team_away:TEAM { id: toInt(csvLine.team_away_id)}),(game:Game { id: toInt(csvLine.id)})
CREATE (team_away)-[:AWAY_TEAM { }]->(game)
WITH csvLine, game
MATCH (team_home:TEAM { id: toInt(csvLine.team_home_id)}),(game:Game { id: toInt(csvLine.id)})
CREATE (team_home)-[:HOME_TEAM { }]->(game)
RETURN game

我认为MATCH导致了这个问题。比赛无法找到比赛。

我做的时候会做游戏: MATCH(游戏:游戏)返回游戏LIMIT 1

{
  "records": [
    {
      "keys": [
        "game"
      ],
      "length": 1,
      "_fields": [
        {
          "identity": {
            "low": 31891,
            "high": 0
          },
          "labels": [
            "Game"
          ],
          "properties": {
            "createdAt": "2014-07-18 19:38:32",
            "deletedAt": "NULL",
            "id": {
              "low": 285,
              "high": 0
            },
            "type": "2",
            "datePlayed": "2013-10-12 04:00:00",
            "updatedAt": "2016-03-25 15:28:41"
          },
          "id": "31891"
        }
      ],
      "_fieldLookup": {
        "game": 0
      }
    }
  ],
}

然而,当我这样做的时候 MATCH(游戏:游戏{id:31891})返回游戏;

  

(没有变化,没有记录)

有人能指出我正确的方向吗?

0 个答案:

没有答案