Check whether records are connected
The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.
Check for a directed path between two records within a chosen number of hops.
Before you run it: False does not rule out a longer path. Reversing the endpoints can change the answer.
First load the order-to-product sample dataset. It creates shop.orders.bought_product with the exact IDs used below.
The sample dataset has a forward link from o001 to p001, so that source/target pair is reachable within one hop. The boolean result does not return the route itself.
- Choose source and targetSupply both record keys and the relation.
- Set the maximum depthBound how many directed links can be followed.
- Read reachable or notThis request checks reachability rather than returning a route.
Follow the example
- Prepare the declared relationship.
- Choose starting and target keys.
- Set a maximum depth.
- Run the reachability request.
Set up the relationship
The relation must be declared in the schema's [[relations]] block. See schemas/reference#relations.
Run the request
curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/graph/shop.orders/path" \
--data-urlencode "rel=bought_product" \
--data-urlencode "src=o001" \
--data-urlencode "dst=p001" \
--data-urlencode "max_depth=3" \
-H "Authorization: Bearer $OC_TOKEN"Check the result
The response tells you whether a path was found within that bound.
{ "reachable": true }One field: reachable: true | false. false means "not within max_depth" - it isn't proof there's no path at higher depth.
Understand the behavior
- Same BFS frontier as bfs, but it stops the instant
dstappears in any expansion. - Worst case (no path) costs the same as a bounded bfs; best case is a single hop.
- Use this over bfs whenever you only need the boolean - the savings come from not materialising the visited set.
Important limits and checks
- Reading
falseas "no path". It only means "no path withinmax_depth". Raise the depth only within a deliberate work limit. Simple-path enumeration is bounded too, so it does not prove unlimited reachability. - Swapping
srcanddston a one-way relation. path is direction-sensitive. If you need the inverse direction, check that the relation is bidirectional.