cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Limit on paths

It seems that limit is not enforced on paths. My query:

match p=(n{name:'Richard Harris'})-[*]-(m{name:'Wil Wheaton'}) return p limit 1

I'm testing on the sample Movie DBMS (v. 4.3.3) in Neo4j Desktop. How should I enforce the limit on the number of paths?

I also tried this one but still I see many nodes and relationships:

match p=(n{name:'Richard Harris'})-[*]-(m{name:'Wil Wheaton'})
With p
limit 1
return p
2 REPLIES 2

Bennu
Graph Fellow

Hi @shayantest2 !

It works. it's just that this path you are getting is too long so you thinks is more than one. Remember that you are using the wildcard *

Bennu

If you're talking about the graphical results view from the Neo4j Browser, then this is because the browser will issue a separate query under the hood to get all the relationships existing between the nodes that were retrieved from your query, so you'll see more relationships than occur in the original query's results. All of the nodes involved however should be along the single path returned from your original query with LIMIT 1.

You can toggle off the 'Connect result nodes' checkbox from the browser preferences.