Get Edge between two vertices

79 views
Skip to first unread message

K Major

unread,
May 15, 2016, 8:54:57 AM5/15/16
to OrientDB
Hi,
I'm simply trying to get the edge between two vertices and get a property weight on this edge.
I tried 
SELECT weight FROM E WHERE in = #11:1820 AND out = #11:12916


but gives me the error : fetched more than 50000 records: to speed up the execution, create an index or change the query to use an existent index

the vertex #11:1820 has only 2 outgoing edges 
  "out": [
                "#11:12916",
                "#11:18051"
            ],

Ivan Mainetti

unread,
May 16, 2016, 1:53:25 AM5/16/16
to orient-...@googlegroups.com
running that query it evaluates all the edges in class E, so it is a normal warning that you are receiving.
Message has been deleted

scott molinari

unread,
May 16, 2016, 2:07:44 AM5/16/16
to orient-...@googlegroups.com
The "out" property in vertex #11:1820 holds the rids to the edges it links to, not the rids to the other vertexes. You need the id of the other vertex as your "out" value in your query.

Scott

K Major

unread,
May 16, 2016, 5:57:24 AM5/16/16
to OrientDB
Indeed, thanks a lot ! 

I'm also wondering if there is a more efficient way to do this query ? 

I think it's not possible to define a index on the 'in' and 'out' fields ?

Luca Garulli

unread,
May 16, 2016, 7:44:10 AM5/16/16
to OrientDB
Hi,
If you define a composite index for "out, in" on E class, your lookups will be much faster. However, check your model if you can avoid indexes by just crossing the edges. Example:

SELECT in()[@rid=#11:1820'].weight as weight FROM #11:12916


Best Regards,

Luca Garulli
Founder & CEO


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scott molinari

unread,
May 17, 2016, 12:57:56 AM5/17/16
to OrientDB
@luca 

I would guess K Major doesn't actually know the rid of the proper edge. So, between the two edge rids he has as "outs" in that vertex, he'd have to find the right one and then get the weight. Your query is assuming the right edge rid is #11:12916. This rid should be unknown to him. If he did know the edge rid, theoretically, couldn't he just do...

SELECT weight FROM #11:12916

??? :-)

Scott
Reply all
Reply to author
Forward
0 new messages