1

I have created a small database with three nodes, Abraham, Isaac and Jacob. Abraham is Isaac's FATHER, and Isaac is Jacob's FATHER.

Now I perform the following query:

MATCH (a:Person), (i:Person)
WHERE a.name='Abraham' and i.name='Isaac'
RETURN a, i

Running the query from the Neo4J web interface shows the two nodes with the FATHER relationship between them: result shown in the Neo4J web interface

This is strange, as I have not requested any relationships. The JSON response doesn't contain the relationships, either:

[{
    "keys": [
        "a",
        "i"
    ],
    "length": 2,
    "_fields": [
        {
            "identity": {
                "low": 0,
                "high": 0
            },
            "labels": [
                "Person"
            ],
           "properties": {
               "name": "Abraham"
           }
      },
      {
          "identity": {
              "low": 1,
              "high": 0
          },
          "labels": [
              "Person"
          ],
          "properties": {
              "name": "Isaac"
          }
      }
  ],
  "_fieldLookup": {
      "a": 0,
      "i": 1
  }
}]

Why is Neo4J showing this relationship? And how can I make it stop? I'm trying to create a query that returns various relationships between a set of nodes, and I really don't want Neo4J interfering and adding its own relationships.

zmbq
  • 38,013
  • 14
  • 101
  • 171
  • 1
    This is the first time I've used the `relationships` tag. Never thought I'd ask for relationship advice on Stack Overflow... – zmbq Aug 07 '17 at 08:51
  • 1
    related https://stackoverflow.com/questions/37603618/how-to-hide-unwanted-relationships-between-nodes-in-neo4j/45121705#45121705 – Tomaž Bratanič Aug 07 '17 at 08:56
  • It's not related, it's a duplicate. I've voted to close (turns out I can't really close my own question...) – zmbq Aug 07 '17 at 09:03

1 Answers1

0

It just the way the Neo4j browser visualizes, nothing more. Since you've got both nodes, Neo4j has everything it needs (the pointers) to know that there is a relationship (and shows it). If you process the result programmatically (in Java or such ... as you're bound to do since I assume the Neo4j browser will not be the "production" result) you will be able to process the results as you wish. If you're only interested in the names and not the actual nodes, just do

MATCH (a:Person), (i:Person)
WHERE a.name='Abraham' and i.name='Isaac'
RETURN a.name, i.name

Hope this helps.

Regards, Tom

Tom Geudens
  • 2,638
  • 9
  • 15