Graphs in RavenDB: What’s the Role of the Middle Man?
Let's take a look at what the role of the middle man is in implementing graph queries. Explore this interesting challenge.
Join the DZone community and get the full member experience.
Join For FreeAn interesting challenge with implementing graph queries is that you sometimes get into situations where the correct behavior is counter-intuitive.
Consider the case of the graph on the right and the following query:
This will return:
- Source: Arava, Destination: Oscar
But what would be the value of the Edge property? The answer to that is…complicated. What we actually return is the edge itself. Let’s see what I mean by that.
And, indeed, the value of Edge in this query is going to be dogs/oscar.
This isn’t very helpful if we are talking about a simple edge like this. After all, we can deduce this from the Src –> Destination pair. This gets more interesting when the edge is more complex. Consider the following query:
What do you think should be the output here? In this case, the edge isn’t the Product property, it is the specific line that matches the filter on the edge. Here is what the result looks like:
As you can imagine, knowing exactly what edge led you from one document to another can be very useful when you look at the query results.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments