Retrieve edge properties via SELECT out("E") from V?

63 views
Skip to first unread message

Charles Bandes

unread,
Apr 27, 2015, 8:18:13 AM4/27/15
to orient-...@googlegroups.com
Hi - I'm building a graph to display via d3's force-directed layout.

In order to find the links, I'm running a query like this:

SELECT expand(out("E")) from V where id=FOO;

This gives me an array of all the objects that are connected to FOO by an edge. That's fantastic.

But I also have a property on the edge called "strength" which indicates the strength of the connection. How do I access that? 

Ideally what I want to get is something like this:

result: [
  {
    object: { THE VERTEX },
    strength: STRENGTH_VALUE
  }
]

Does that make sense? Am I going about it all wrong? 

Johan Sjöberg

unread,
Apr 27, 2015, 12:24:10 PM4/27/15
to orient-...@googlegroups.com
A solution (there is in fact multiple ways to go about it) would perhaps be the following:

SELECT in.*, strength FROM (SELECT outE("E") FROM FOO)

What this does is that it first selects the edge and then selects anything of interest. By doing this you follow the path as it is saved in the database and the performance should be rather good.
Note that I start from the id FOO. This is also a performance improvement, instead of first finding FOO and then traverse we start from FOO straightaway. 

This does not however return the data as you want, it will be returned as one single non-nested json. But that shouldn't be a problem for you to handle I believe.

CMB

unread,
Apr 27, 2015, 12:59:39 PM4/27/15
to orient-...@googlegroups.com
Hi Johan, this gets me very close, but I still need a way to get the complete in.* object, not just its @rid, that's why I was using SELECT expand()

Is there a way to do something like that with your approach?

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/NZK91MmB8_M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johan Sjöberg

unread,
Apr 27, 2015, 2:22:45 PM4/27/15
to orient-...@googlegroups.com
in.* should give you the complete object and not just the @rid since I select all of the in vertex's properties.

But I suppose you could try:

select *, inE('E').strength from (select expand(out('E')) from FOO)

But that will give you a list of strength values and it is hard to determine which is the correct one if you have multiple.  

The first solution really should work though, what do you get when you try the first method?

CMB

unread,
Apr 27, 2015, 2:34:05 PM4/27/15
to orient-...@googlegroups.com
I actually don't get any results at all from this:

SELECT in.*, strength FROM (SELECT outE("Friend") FROM #11:111)

I do get a result from this
SELECT outE("Friend") FROM #11:111

The closest I've come so far is running two queries and then hoping they sort their results the same way

SELECT expand(out("Friend")) FROM #11:111
SELECT outE("Friend").strength FROM #11:111

And then loop through the two resulting arrays to make objects of {friend:FOO, strength:BAR}
(Which seems like a pretty lousy solution (it also doesn't work right now))
Reply all
Reply to author
Forward
0 new messages