NEO4J error : Invalid input 's': expected 'n/N'

358 Views Asked by At

For the below cypher query, I am getting an error

Cypher Query tried:

match (n:attribAct) where not tolower(n.Aliases) contains tolower(n.name) set n.Aliases = n.name+","+n.Aliases as x return x;

Error:

Invalid input 's': expected 'n/N' (line 1, column 115 (offset: 114))
"match (n:attribAct) where not tolower(n.Aliases) contains tolower(n.name) set n.Aliases = n.name+","+n.Aliases as x return x;"

How could I fix this problem? Thank you so much!

2

There are 2 best solutions below

0
jose_bacoy On

As @BurakSerdar said, the SET command does not need an alias.

Your code:

match (n:attribAct)
where not tolower(n.Aliases) contains tolower(n.name)
set n.Aliases = n.name+","+n.Aliases as x
return x;

FIX:

match (n:attribAct) 
where not tolower(n.Aliases) contains tolower(n.name) 
set n.Aliases = n.name+","+n.Aliases 
return n;
0
cybersam On

The AS keyword can only be used in WITH and RETURN clauses.

You can return n this way:

MATCH (n:attribAct) 
WHERE NOT TOLOWER(n.Aliases) CONTAINS TOLOWER(n.name) 
SET n.Aliases = n.name + "," + n.Aliases 
RETURN n;

By the way, if n.Aliases was actually a list of strings (instead of a comma-delimited string), this would work:

MATCH (n:attribAct) 
WHERE NONE(a in n.Aliases WHERE TOLOWER(a) = TOLOWER(n.name)) 
SET n.Aliases = n.Aliases + n.name
RETURN n;