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. 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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments