filter by edge property both ways

83 views
Skip to first unread message

Mihai Pricop

unread,
Mar 17, 2015, 9:28:17 AM3/17/15
to orient-...@googlegroups.com
HI, I am new to OrientDB and I tried to play with it for the last month, but now I started some tasks and bumped in some problems.

My problem for now is the following:

I have a structure:
 - User - a vertex, with property id and services
 - worked - an edge, with property recommendation (a string with a few possible values)

I need to find all nearby Users of a certain User that have a relationship of the type 'worked' with a certain property (let's say: 'recommended'); this in my vision will translate as:

select expand( both()[recommendation='recommended'] ) from <@rid>

But this query does not return anything.

I'm running OrientDB 1.7.4.

Hope someone can help me,
Thank you.

-----------------------------------------------------------------------

EDIT 1:

I provided the actual schema above.

Sample data:
 - Users:
     -> user1; id=1; services=[{name:'service1'},{name:'service2'}]
     -> and a couple of more users; let's say we have 10 users that are connected as following
 - Edges:
     -> (1) user1 --(worked)[recommendation='recommended']--> user2
     -> (2) user1 --(worked)[recommendation='not recommended']--> user3
     -> (3) user2 --(worked)[recommendation='recommended']--> user4
     -> (4) user2 --(worked)[recommendation='pending']--> user5
     -> (5) user3 --(worked)[recommendation='pending']--> user6
     -> (6) user3 --(worked)[recommendation='recommended']--> user7
     -> (7) user5 --(worked)[recommendation='not recommended']--> user1
     -> (8) user7 --(worked)[recommendation='recommended']--> user1

If we want to find the users that are recommended in the network on level 1 for user1, we want to find: user2 (1) and user 7 (8). Users 5 and 3 will not be found because the label is wrong (we are looking for edges with recommendation property set on 'recommended') .

To extend this, I want to look to second level. Looking at user1, I should find: user4(1)(3) and user7(8)(6). Ofc I would not want to repeat the users that were in level 1, but I think this could be done with a select where not in level1. 

Hope this will clear out what I need and hope someone can help.

nagaraja sosale ramaswamy

unread,
Mar 17, 2015, 1:16:37 PM3/17/15
to orient-...@googlegroups.com
it would help if you can provide the actual schema and sample data along with the expected result


~nagu.

Mihai Pricop

unread,
Mar 17, 2015, 2:18:37 PM3/17/15
to orient-...@googlegroups.com
I updated the post with an exemplification of what I want. Hope this will clear things out.

--

---
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/MCeUchXP-DU/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.

Mihai Pricop

unread,
Mar 19, 2015, 10:21:44 AM3/19/15
to orient-...@googlegroups.com

As vitorenesduarte suggested, I found the answer. Yes I should look for edges, filter the edges, than take out the vertices from the edges, like following:

select expand( unionAll(inE('knows')[method='friend'].out, outE('knows')[method='friend'].in ) from <rid>

The problem with this query is that I think it could be optimized if OrientDB would have a function to take both way vertices from edges, something like this:

bothE('knows')[method='friend'].both

But the .both function doesn't exist (at least in the version I use, which is 1.7.4). If anyone knows something about this, please leave a comment.


Reply all
Reply to author
Forward
0 new messages