使用密码查询语言错误消息"WITH is required between CREATE and MATCH"一次添加多个关系



我是Neo4J的新手,在向DB添加数据时遇到了问题。我使用的是本地运行的Neo4J社区版,所以我通过web界面输入所有查询。

我正在用推特作为一种学习练习来构建一个概念图。我已经添加了三种类型的节点,如下所示:

推特节点

CREATE (t0:Tweet {id: '0', twitterId: 'ke', twitterName: 'KennyDMcC', created_at: '04/11/2022', text: '@calebsaysthings And as far as we know she’s still goin. 😄  #uk #england #scotland #wales #greatbritain #lanarkshire #glasgow #politics #monarchy #TheQueen', src_url: 'http://twitter.com/download/iphone'})
CREATE (t125:Tweet {id: '125', twitterId: 'ke', twitterName: 'kennethmac2000', created_at: '04/11/2022', text: '@Baldred @Lindy_Loo15 @DalgetySusan @scotgov Hear, hear.  Also Linda, are you seriously suggesting that it should be a criminal offence for a Canadian national to come to the UK and participate in UK politics? If not, Im not sure what you are suggesting.', src_url: 'https://mobile.twitter.com'})
CREATE (t1:Tweet {id: '1', twitterId: 'ca', twitterName: 'cath_data', created_at: '04/11/2022', text: '@RagingAnecdotes Must be nice to have options: ', src_url: 'https://mobile.twitter.com'})

推特用户

CREATE (ke:Twitterer {id: 'ke', name: 'KennyDMcC'})
CREATE (ca:Twitterer {id: 'ca', name: 'cath_data'})
CREATE (re:Twitterer {id: 're', name: 'Record_Politics'})

标签

CREATE (uk:HashTag {id: 'uk', tag: '#uk'})
CREATE (england:HashTag {id: 'england', tag: '#england'})
CREATE (scotland:HashTag {id: 'scotland', tag: '#scotland'})

所有这些都如预期的那样工作,我已经添加了大约500条推文、125条推文和大约100个哈希标签。我通过创建一个python脚本来实现这一点,该脚本创建CREATE语句并将它们写入文本文件。然后我将查询复制/粘贴到neo4j浏览器中。

我遇到的问题是,当我试图在建立关系时做同样的事情。我可以单独添加以下内容,但一旦我尝试像添加节点一样添加它们,复制/粘贴整个列表,我就会收到一条错误消息。

MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '72' AND h.id = 'fordereport'
CREATE (t)-[w40:TAGGED {date: '04/11/2022'}]->(h)
MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '72' AND h.id = 'hypocrisy'
CREATE (t)-[w41:TAGGED {date: '04/11/2022'}]->(h)
MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '75' AND h.id = 'nhs'
CREATE (t)-[w42:TAGGED {date: '04/11/2022'}]->(h)

错误信息显示

Neo.ClientError.Statement.SyntaxError
WITH is required between CREATE and MATCH (line 5, column 1 (offset: 126))
"MATCH (t:Tweet),(h:HashTag)"
^

我尝试了许多不同的方法来输入数据,但都无法获得正确的格式。我要建立多种关系,我真的不想一个接一个地建立1000种关系。

我有";启用多语句查询编辑器";已检查设置。

简单答案!我想这是一个很难找到的问题。

查询之间的CCD_ 1解决了这个问题。这就是我制作的作品。

MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '0' AND h.id = 'uk'
CREATE (t)-[w1:TAGGED {date: '04/11/2022'}]->(h)
;
MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '0' AND h.id = 'england'
CREATE (t)-[w2:TAGGED {date: '04/11/2022'}]->(h)
;
MATCH (t:Tweet),(h:HashTag)
WHERE t.id = '0' AND h.id = 'scotland'
CREATE (t)-[w3:TAGGED {date: '04/11/2022'}]->(h)
;

相关内容

  • 没有找到相关文章

最新更新