简体   繁体   English

如何在Neo4J中创建子串的关系

[英]How do I create relationships from substrings in Neo4J

I have a set of 'tag' nodes and 'category' nodes, and wanted to generate relationships between the two by testing if the category's name is a substring of the tag's name. 我有一组“标记”节点和“类别”节点,并希望通过测试类别的名称是否是标记名称的子字符串来生成两者之间的关系。 This was my approach thus far (apologies, I'm one day into cypher so this may be fundamentally flawed but I am yet to find something equivalent to reverse engineer thus far) 到目前为止,这是我的方法(道歉,我有一天进入密码所以这可能存在根本性的缺陷,但到目前为止我还没有找到相当于逆向工程的东西)

match(cat:category)
match(tag:tag) where tag.name =~ '.*'+cat.name+'.*'
merge (tag)-[:belongs_to]-(cat)

Error: 错误:

Type mismatch: expected Boolean, Collection<Boolean> or Collection<Collection<Boolean>> but was String (line 2, column 48 (offset: 67))
"match(tag:tag) where tag.name =~ '.*'+cat.name+'.*'"

The error seems to revolve around the use of =~ and concatenated strings, any advice would be appreciated! 错误似乎围绕使用=〜和连接字符串,任何建议将不胜感激!

The problem is with the order in which the expression in the WHERE clause is evaluated. 问题在于评估WHERE子句中的表达式的顺序。 You can get around it by being explicit: enclose the string concatenation in parentheses. 您可以通过显式来绕过它:将字符串连接括在括号中。

WHERE tag.name =~ ('.*' + cat.name + '.*')

I tried quickly looking for documentation on cypher operator precedence but it wasn't in the operator chapter , so I'm not sure where this is documented. 我试着快速查找有关cypher运算符优先级的文档但是它不在运算符章节中 ,所以我不确定它在哪里记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM