简体   繁体   中英

When doing a match with the traverse function with all equals

In Orient DB, I understand a query like this:

match 
  {class: someNode, as: someNode, where: (id='123')}
  .out() {class: someNode as: relatedNode, while:(true), where:(relevance = true)}
return
  someNode

Will return someNode with ID 123 if any outnodes has relevance = true. However, what if i want ALL outgoing nodes to be relevance = true connected to someNode? Can I still do a match starting at someNode 123 going out where all = true?

You can try the following:

match 
  {class: someNode, as: someNode, 
   where: (id='123' AND out()[relevance != true).size() = 0}
return someNode

[edit]

If you need also connected nodes with the same features, you can do the following:

match 
  {class: someNode, as: someNode, 
   where: (id='123' AND out()[relevance != true).size() = 0}
  .out(){class: someNode, as: anotherNode, 
      while: (relevance = true AND out()[relevance != true).size() = 0)
      where: (relevance = true AND out()[relevance != true).size() = 0}
return someNode

You can change the WHILE and WHERE conditions to slightly change the behavior regarding which nodes you want to include/exclude based on relevance flag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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