Reputation: 51
Please apologize, I'm new on stackoverflow and completely new to OrientDB. I have the following, simple test-structure in OrientDB: different connected nodes, which have a list of tags as property
I want to show only the part of the graph (nodes with their edges), which have a intersection at the tags. This should be for this example, the highlighted red node and the smooth red once with the edge PRAESENTIERT_BEI.
In Neo4j, it is very easy. You just look for the start-node, traverse over all connections and compare the property with a filter like the following code example:
MATCH (n:ConferenceSerie)
MATCH p = n-[*]-m WHERE FILTER(x IN n.flag WHERE x IN m.flag)
RETURN p
But I have no idea how to handle it on OrientDB. I thought it could be done with TRAVERSE, and the intersect() function, but I have no idea how to compare the property of two nodes.
Is there any chance to create a SQL-query which shows the subgraph?
Thanks in advance.
Upvotes: 0
Views: 306
Reputation: 3570
I used the field tags as EmdeddedList of String
create class A extends V
create property A.tags EmbeddedList String
create class B extends V
create property B.tags EmbeddedList String
create class C extends V
create property C.tags EmbeddedList String
create class D extends V
create property D.tags EmbeddedList String
create class E1 extends E
create class E2 extends E
create class E3 extends E
insert into A(tags) values(["http"]) //#12:0
insert into B(tags) values(["www","cs","at"]) //#13:0
insert into C(tags) values(["www","papers","com"]) //#14:0
insert into D(tags) values(["https"]) //#15:0
create edge E1 from 12:0 to 13:0
create edge E2 from 14:0 to 13:0
create edge E3 from 14:0 to 15:0
Try the following query
select expand(list) from (select $d as list from e
let $a=(select in.tags as tags from $parent.$current unwind tags),
$b=(select out.tags as tags from $parent.$current unwind tags ),
$c=intersect($a.tags,$b.tags),
$d=unionAll(@rid,out.@rid,in.@rid)
where $c.asList().size()>0)
Upvotes: 0