Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

In Neo4J 3.5 I set up the native indexes on a certain type (:IN) of my relationships and I'm using this to query them, which works fine:

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship RETURN DISTINCT relationship;

However, in APOC I was able to also query the start and the end node of a relationship, using a query like:

CALL apoc.index.relationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD start,end RETURN DISTINCT start, end;

Which was very helpful.

When I try to do

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD start, end RETURN DISTINCT start, end;

It doesn't work.

So what option do I have if I want to retrieve not the actual relationships, but, rather the nodes they are linking?

This should work:

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship
RETURN DISTINCT STARTNODE(relationship) AS start, ENDNODE(relationship) AS end;
                No, this is not working. But what works is: ` YIELD relationship WITH DISTINCT relationship, startNode(relationship) AS start, endNode(relationship) AS end RETURN start, end;` — also it's much slower than apoc.index.relationships. Do you know if it's normal?
– Aerodynamika
                Apr 23, 2020 at 18:28
                See my updated answer, which is simpler. I do not know the internals of the 2 procedures.
– cybersam
                Apr 23, 2020 at 18:54

This get connected nodes

CALL db.index.fulltext.queryRelationships('IN','user:16c01100-aa92-11e3-a3f6-35e25c9775ff') YIELD relationship, score
match (node)-[relationship]-(b)
RETURN node, b
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.