问题
MATCH (p:Product {id:'19134046594'})-[r]-> (o:Attributes {4g:'network'}) return o
I received this exception:
Exception in thread "main" java.lang.RuntimeException: org.neo4j.driver.v1.exceptions.ClientException: Invalid input ':': expected an identifier character, whitespace or '}' (line 1, column 66 (offset: 65))
It's complaining about '4g'. Is '4g' an invalid property key identifier in neo4j? How to work around the issue?
回答1:
You can use the backtick (`) character to quote property names that start with an otherwise illegal character.
For example, this would work:
CREATE (o:Attributes {`4g`: 'network'})
RETURN o;
And this also works:
MATCH (o:Attributes) WHERE o.`4g` = 'network'
RETURN o;
回答2:
According to the naming rules section of the documentation, names you use (which does include property keys):
Must begin with an alphabetic letter.
and
Can contain numbers, but not as the first character.
You can however start it off with an underscore, so _4g:'network'
would work.
I'm guessing this is just for example purposes, but it does seem to me that it would be better the other way around: network:'4g'
.
来源:https://stackoverflow.com/questions/50012666/can-a-neo4j-identifier-start-with-an-integer