0
votes

I'm trying to pile a load of Twitter data into Neo4J using the .Net Neo4JClient. It's essentially the same type of Twitter user data for each node, but some of the nodes have a different significance to others, hence I would like to label them differently.

(I'm brand new both to Neo4J and the client, too).

So I've been trying to label them like so:

var query = _client.Cypher
              .Create("(primaryNode:nodeLabel {twitterUser})")
              .WithParams(new { nodeLabel = "nodeType", twitterUser } );


query.ExecuteWithoutResults();

Note: I split out the ExecuteWithoutResults so I could debug the query, and it is registering the parameters OK. The documentation here:

https://github.com/Readify/Neo4jClient/wiki/cypher#explicit-parameters

... suggests that parameters can be created "at any point in the fluent query" - but the Neo documentation about parameters here:

http://docs.neo4j.org/chunked/1.8.2/cypher-parameters.html

... kind of suggests otherwise, that parameters are specifically for things like WHERE clauses, indexes and relationship Ids.

Anyway - when I execute the above, I get a shiny new node with the label "nodeLabel" - so the parameter ain't working. Could somebody clarify whether or not I'm just making a dumb newbie mistake?

1

1 Answers

2
votes

You can call WithParams whenever you want in the query. That's what the Neo4jClient doco means about "at any point in the fluent query".

However, Neo4j only supports parameters in certain parts of the Cypher text. If the parameter would affect the query plan, it's not allowed.

In this case, you cannot use parameters for labels. You will need to actually construct the query dynamically if you want to do that.

Edit: Even if this was a supported place for parameters, you'd at least have to write {nodeLabel} in your Cypher instead of just nodeLabel.