So this was a lesson learned on what the Merge keyword actually does. In a previous query, I was Merging what I thought were two queries to get the likes for an item, after querying for the item. The Merge statement was creating a new user node per like with a like relationship.
I did rewrite the query that I spoke of above and have something that looks like this:
client.Cypher
.Start(new { n = string.Format("node({0})", nodeId) })
.Match("(u:User {ProviderUserKey : {id}})")
.WithParam("id", id)
.Create("(n)-[:Liked_By]->(u)").ExecuteWithoutResults();
Which has the desired effect of only creating a relationship. Thank you to @BtySgtMajor for getting my on the right track to figure this out (by mentioning the relationship.
For those playing along at home here was the offending query:
var result = client.Cypher.Start(new { s = string.Format("node({0})", id) })
.Match("(u:User)<-[mb:Created_By]-(c:Comment)-[o:On_Item]->(s:Session)")
.Merge("(c)-[lb:Liked_By]->(lbu:User)") //bad line here
.Return((u, mb, c, s, o, lbu) =>
new { Comment = c.As<Comment>(), MadeByUser = u.Node<UserInfo>(), CommentNodeId = c.Id(), LikedByUsers = lbu.CollectAs<UserInfo>() })
.Results.Select(x =>
{
x.Comment.MadeBy = x.MadeByUser.Data;
x.Comment.MadeBy.NodeId = (int)x.MadeByUser.Reference.Id;
x.Comment.MadeBy.ProviderUserKey = x.MadeByUser.Reference.Id;
x.Comment.Id = (int)x.CommentNodeId;
x.Comment.LikedBy = x.LikedByUsers.Select(ui => new UserInfo { Username = ui.Data.Username, ProviderUserKey = ui.Reference.Id, NodeId = (int)ui.Reference.Id }).ToList();
return x.Comment;
});
I changed the Merge to an OptionalMatch and it was no longer creating the errant user nodes!
However, I feel this is not a clean implementation, and that there is a better way to write this query. I'll raise it in another question.