-
This appears to be similar to https://github.com/orgs/surrealdb/discussions/18, but more specific, and hopefully, this question will get more traction than that question. Can graph queries traverse? In Neo4J I can do something like this MATCH (device:Device a list of devices that are associated with this device
OPTIONAL MATCH (device)-[:similar*0..]-(devices:Device)
MATCH (devices)<-[:compatible]-(item:Item)
RETURN id(item) as id Is this possible with SurrealDB, or could it be possible in the future? Can I create directionless/bi-directional relations? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Just wanted to bump this since graph traversals and bidirectional relationships seem broadly useful. |
Beta Was this translation helpful? Give feedback.
-
+1 for graphql traversals. I prefer ArangoDB syntax https://www.arangodb.com/docs/stable/aql/graphs-traversals.html This is a good example: https://www.arangodb.com/events/graphs-of-game-of-thrones/ |
Beta Was this translation helpful? Give feedback.
-
FYI: I'm completely new to SurrealDB and the whole graph database paradigm. I found this example on https://surrealdb.com/features -- Select all 1st, 2nd, and 3rd level people who this specific person record knows, or likes, as separate outputs
SELECT ->knows->(? AS f1)->knows->(? AS f2)->(knows, likes AS e3 WHERE influencer = true)->(? AS f3) FROM person:tobie; If you implement -- c1 are compatible items, s1 are similar devices, c2 are compatible items of similar devices
SELECT <-compatible<-(? AS c1), <->similar<-(? as s1)<-compatible<-(? as c2) FROM device:c
-- selects compatible items from c, similar devices, similar devices of similar devices and similar devices of similar devices of similar devices :smile:
SELECT <-compatible<-(? as c) FROM (SELECT array::distinct(<->similar<->?<->similar<->?<->similar<->?) FROM device:c) I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I wonder why nobody has answered this very important question. If this graph traversal functionality is indeed still lacking it greatly limits its usefulness as a graph database. As others mentioned ArangoDB has this ability and it works great. |
Beta Was this translation helpful? Give feedback.
-
Hi @clarkmcc . We agree that arbitrary-hop queries are very important functionality to have. We hope to have that supported in the future, but until then it can be achieved with JS functions. Regarding directionless graphs, you can make a query using both directions with the Hopefully the above answer are useful. (This answer was edited on 2024/02/19) |
Beta Was this translation helpful? Give feedback.
-
Any updates on when graph traversal features may be implemented? Were you able to add it to the roadmap? |
Beta Was this translation helpful? Give feedback.
Hi @clarkmcc . We agree that arbitrary-hop queries are very important functionality to have. We hope to have that supported in the future, but until then it can be achieved with JS functions.
Regarding directionless graphs, you can make a query using both directions with the
A<->r<->B
syntax. This will capture relations that are going in either direction. Not exactly the same as directionless, but a viable substitute in most cases.Hopefully the above answer are useful.
(This answer was edited on 2024/02/19)