Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Length Cypher Query over all Relationship Types #30

Closed
stevemarin opened this issue Aug 16, 2021 · 4 comments
Closed

Variable Length Cypher Query over all Relationship Types #30

stevemarin opened this issue Aug 16, 2021 · 4 comments

Comments

@stevemarin
Copy link

Hello! Thank you VERY much for the great tool and, especially, for all the great docs & examples!

I'm trying to perform a query like:

MATCH p=(from)-[rel *1..3]->(to) WHERE from.name = "Bob" AND to.name = "Frank" RETURN p

I.e. All paths of length 1..3 from "Bob" to "Frank" regardless of the relation type. I see how to do a variable length query with certain relationships, but not with all. Am I missing something in the docs? I have all the relationship types, so I could just build a string (:FRIENDS_WITH:RELATED_TO:DATED) and add the *1..3 at the end. But I just want to see if I'm missing something before I add that complexity. THANK YOU!

@stevemarin
Copy link
Author

stevemarin commented Aug 16, 2021

Sorry, it's working. My problem was using a WHERE clause to filter results based on relation properties. My relations have dates, and I'm trying to filter such that I get all results between two dates. I'm seeing the issue:

DatabaseError: Only nodes, edges and maps have properties to be looked-up.

How would I filter edges with dates as properties while using a variable number of any type of edge?

@stevemarin
Copy link
Author

Again, sorry. This should probably be on the discussion board. Closing.

@gitbuda
Copy link
Member

gitbuda commented Aug 16, 2021

Hi! Thank you for your kind words! You can also use filter lambda with any variable length path expression, an example is here https://docs.memgraph.com/memgraph/reference-guide/graph-algorithms#breadth-first-search :D Memgraph actually doesn't support time data types yet, you have to use integer or string for the time representation at this point. But, the next release in the middle of September is going to have temporal types supported. Stay tuned for that :D

@MasterMedo
Copy link

Also, instead of using the where clause you can specify the attributes withing the match clause:

MATCH p=(from {name: "Bob"})-[rel *1..3]->(to {name: "Frank"}) RETURN p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants