Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:30:42+00:00 2026-06-14T04:30:42+00:00

Am trying to get the basics down before moving forward with neo4j. Love the

  • 0

Am trying to get the basics down before moving forward with neo4j. Love the querying aspect but now trying to delete using neo4jclient and stuck.

Simple setup
root-[:has_user]->user
and
user-[:friends_with]->friend`

For a user with the Id of 1 I would like to remove the specified from Id == 2. User 1 is no longer friends with User 2 🙁

Anyway, using neo4jclient I first check to make sure that the users are friends in the first place with this:

if (client.Cypher.Start("root", client.RootNode)
    .Match("root-[:HAS_USER]->user-[:FRIEND]->friend")
    .Where((UserNode user, UserNode friend) => user.Id == 1 && friend.Id == id)
    .Return<Node<UserNode>>("user")
    .Results
    .Count() == 1)
{

now I’m trying to delete:

    client.Cypher.Start("root", client.RootNode)
        .Match("root-[:HAS_USER]->user-[r]->friend")
        .Where("user.Id = 1")
        .And()
        .Where("friend.Id = " + id)
        .And()
        .Where(string.Format("type(r) = 'FRIEND'"))                
        .Delete("r");
}

No errors, but the relationship is still there. Any ideas?

Update 11/12/2012

Got it working. I first updated by Neo4J instance with the stable 1.8. I think something with the latest neo4jclient and neo4j server were not working together. I first got the user’s node based on the id, then from that node tested if the node had a relationship, then was able to remove it. Code below:

        var currentUserNode = client.Cypher.Start("root", client.RootNode)
            .Match("root-[:HAS_USER]->user")
            .Where((UserNode user) => user.Id == 1)
            .Return<Node<UserNode>>("user")
            .Results.Single();

        if (currentUserNode.StartCypher("user")
                .Match("user-[r]->friend")
                .Where("friend.Id = " + id).And()
                .Where("type(r) = 'FRIEND'")
            .Return<Node<UserNode>>("user")
            .Results
            .Count() == 1)
        {

            currentUserNode.StartCypher("user")
                .Match("user-[r]->friend")
                .Where("friend.Id = " + id).And()
                .Where("type(r) = 'FRIEND'")
                .Delete("r").ExecuteWithoutResults();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:30:44+00:00Added an answer on June 14, 2026 at 4:30 am

    One way is to switch to use a CypherFluentQuery instead:

    new CypherFluentQuery(client)
        .Start("root", client.RootNode)
        .Match("root-[:HAS_USER]->user-[r]->friend")
        .Where("user.Val = 1").And()
        .Where("friend.Val = " + 2).And()
        .Where("type(r) = 'FRIEND'")
        .Delete("r").ExecuteWithoutResults();
    

    which will do what you want.

    I believe this all stems from a bug: https://bitbucket.org/Readify/neo4jclient/issue/40/should-be-able-to-add-cypher-delete-clause

    As to why client.Cypher.Start isn’t working as it should, I’m not sure, the bug is fixed, and should be working from version 1.0.0.479 (current at time of writing is 1.0.0.496)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just trying to get the basics down of using Admob in my android
I'm trying to get the basics down here of class definition and using a
I've got the basics of LINQ-to-SQL down, but I've been struggling trying to get
I'm learning rails and I'm just trying to get the basics down. I just
I'm trying to get the basics of iOS programming down. I have an app
I'm new to PHP and have the basics down but now I have a
I'm trying to get the basics of an Android app that sends and receives
I'm trying to get a basic sample across domains working, but I just cannot
Im using xmpp4r and trying to get the hang of a basic chat feature
I am entirely new to XML Schema and am trying to get the basics

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.