Neo4j含特殊字符或URL的属性查询报错解决方法
Got it, let's sort out that Cypher query issue you're facing with special characters in property names! The error happens because Cypher's dot notation (n.property) doesn't play nice with property names that have symbols like @, slashes (from URLs), or other non-standard identifiers. Here's how to fix it:
Correct Syntax for Special Property Names
Instead of using dot notation, wrap the property name in square brackets paired with quotes (either single or double quotes work—pick whichever avoids conflicts with your property's content).
1. Querying the @audit Property
Replace your original query with this:
MATCH (n) WHERE n["@audit"] = "true" RETURN n
Or if you prefer single quotes:
MATCH (n) WHERE n['@audit'] = "true" RETURN n
2. Querying URL-Based Property Names
The exact same approach works for URLs used as property names. For example, if you have a node with a property named https://example.com/user/profile, your query would look like this:
MATCH (n) WHERE n["https://example.com/user/profile"] = "active" RETURN n
Quick Bonus Tip
If your property name includes quotes (like user"settings), mix quote types to avoid syntax errors:
// Use single quotes around the property name that has double quotes MATCH (n) WHERE n['user"settings'] = "dark_mode" RETURN n
内容的提问来源于stack exchange,提问作者sumit

