4

I'm new to Neo4j and trying to do a simple Cypher query using a lambda expression in the where clause but for some reason I can't seem to figure out why this isn't working.

Looks like:

class HealthNode { 
    public string Name{get;set;}
    //Other Stuff
}
string Name = "Foobar";

var query = client
    .Cypher
    .Start(new { n = Neo4jClient.Cypher.All.Nodes })
    .Where((HealthNode n) => n.Name == Name)
    .Return<HealthNode>("n");        

If I dump the Text and Parameters I'm getting:

START n=node(*)
WHERE (n.Name! = {p0})
RETURN n
//P0 Foobar

When I execute this, I of course get:

Cypher does not support != for inequality comparisons. Use <> instead

Why in the world is an extra Exclamation point to the name of the variable?

Warren Y
  • 41
  • 1

3 Answers3

0

The ! means that the result will be false if the property doesn't exist. So, if you have more than one type in the graph, and that other type doesn't have a 'Name' property, neo4j won't bother matching.

See Neo4J Documentation for more info.

As to getting the != warning, are you changing the query at all when you paste it? Reformatting it? As I get the same warning if I do:

WHERE (n.Name != {p0})

but don't get any warning, and a successful completion if I use:

WHERE (n.Name! = {p0})
Charlotte Skardon
  • 6,220
  • 2
  • 31
  • 42
  • I used copy/paste to get the exact text. – Warren Y Aug 25 '13 at 19:21
  • Where are you pasting to? As long as there is a space between the `!` and the `=` you shouldn't get the error. If you run this query: `START n=node(0) WHERE n.Name! = "TEST" RETURN n;` in the cypher console does that show the same error? – Charlotte Skardon Aug 25 '13 at 19:33
  • I used copy/paste to get the exact text, and I also went to the shell itself and typed it in personally just in case there was a hidden character, but the parser returned the same error. (sorry about the poor formatting, I don't have the hang of this site yet) `START n=node(*) WHERE (n.Name! = "FOO") RETURN n;` returns the error on my local server (2.0.0-M04 Windows Community) Oddly enough, the same exact query runs fine if I execute it against the live sample databases at [http://www.neo4j.org/learn/try] I wonder if this is a bug in the parser in this particular version on the windows build? – Warren Y Aug 25 '13 at 19:38
  • Good catch, the online samples presumably run the stable version 1.9x not 2.0 – Charlotte Skardon Aug 26 '13 at 06:21
0

I think I found the cause of the problem here:

There was a change made to the 2.0 parser that implements NULL IF by default (instead of returning an error on a missing property) and removes the ! and ? operators since they no longer do anything.

neo4j pull request 1014 I suspect this will break a lot of things and not just Neo4J Client.

Warren Y
  • 41
  • 1
0

Fixed in Neo4jClient 1.0.0.625 and above, when talking to Neo2j 2.0.

Tatham Oddie
  • 4,290
  • 19
  • 31