简体   繁体   English

OrientDB查询比较

[英]OrientDB query compare

I have the following doubt to query in OrientDB. 我在OrientDB中有以下疑问要查询。

I have three vertex users, events and sports. 我有三个顶点用户,事件和运动。

First users choose sports and at that point the has_sport edge is created, which has the 'out' on the user and 'in' on the sports. 首先,用户选择运动,然后创建has_sport边缘,该边缘在用户上为“ out”,在运动上为“ in”。

And having some events registered by other users as follows, users-> events-> sports, users create edge 'out' and 'in' events and events edge 'out' and 'in' sports. 并在其他用户(用户->事件->体育)中注册了一些事件,用户创建边缘“出”和“入”事件,事件创建边缘“出”和“入”运动。

Now the question of how to do the query, I want to make a query that returns the events to the user according to the sports that he chose. 现在是有关如何进行查询的问题,我想进行查询,以根据用户选择的运动将事件返回给用户。 In other words, to see if the user sports is equal to the events sport. 换句话说,查看用户运动是否等于事件运动。

Vertex: users, events, sports Edges: has_sport, has_event 顶点:用户,事件,运动边缘:has_sport,has_event

Image graph 图像图

Sorry for my bad english hehe 对不起,我英语不好

Thank you 谢谢

EDIT 编辑

    SELECT expand(event) FROM (
      MATCH 
        {class:users, as:user, where:(userId = ?)} -has_sport-> {as:sport},
        {class:events, as:event} -has_sport-> {as:sport},
        {as:user} -has_sport-> {as:sport}
    RETURN event
    )

You can consider using a MATCH statement: 您可以考虑使用MATCH语句:

MATCH 
  {class:User, as:user, where:(userId = ?)} -has_event-> {as:event} -has_sport-> {as:sport},
  {as:user} -has_sport-> {as:sport}
RETURN event

This will return the event RIDs. 这将返回事件RID。 If you want expanded records, you can wrap it in a SELECT expand() eg. 如果要扩展记录,可以将其包装在SELECT expand()

SELECT expand(event) FROM (
  MATCH...
)

Hope this works.. 希望这可以..

select out.name as sports, in('has_event').name as eventname from (select expand(out('has_sport')) from User where userid = 151)

Please verify the "out" / "in" logic. 请验证“输出” /“输入”逻辑。 if required change it. 如果需要,请进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM