I've recently started working on Cypher. Created a Book
database. I want to implement following things using Cypher query-
- Find all books containing at least 1 capital letter in its
isbn
property value. - Traverse over all of such books and for each book if one more book(node) is present with same value but in small case(If other node is present then it'll always have small case isbn value) then add label to capital value node with name
Deleted
. - If only one node present with capital value then convert its value into small case.
Following is the query I wrote, but getting error about unexpected case-
CALL apoc.periodic.iterate(
'MATCH (res:Book) WHERE res.isbn =~ \'.*[A-Z]+.*\' RETURN res',
'MATCH (res2:Book) WHERE toLower(res.isbn) = toLower(res.isbn)
RETURN count(res2) as rescount WITH CASE rescount
WHEN 1 THEN set res.isbn=toLower(res.isbn)
WHEN 2 THEN set (res:Deleted) END',{})
Error-
{"Invalid input 'r': expected whitespace, comment, '{', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, '(', '.', node labels or rel types, '[', '^', '*', '/', '%', '+', '-', "=~", IN, STARTS, ENDS, CONTAINS, IS, '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, WHEN, ELSE or END (line 3, column 21 (offset: 187))\n" WHEN 1 THEN set res.isbn=toLower(res.isbn)"\n ^": 1 }