Search code examples
orientdb

OrientDB - show both edge and vertex properties


I have vertex class host with property hostname and edge class link with property ports which is a list.

So hosts are connected to each other with link having ports.

I need to find out who is connected to one specific 'myhost' like:

host1.hostname -- link1.ports 
host2.hostname -- link2.ports
etc

However, I'm only able to achieve:

host1@rid -- ports1 
host2@rid -- ports2

with query like:

select expand(inE(link).include('ports','out*')) from host where hostname = 'myhost'

or I can get hostnames and ports as list, yet not very useful:

[host1.hostname, host2.hostname] -- [link1.ports, link2.ports]

select in('link').hostname,inE('link').ports from host where hostname = 'myhost'

Unwind in that query doesn't do the thing, too.

Is there any proper way to do it?


Solution

  • Did you try the Match statement?

    https://orientdb.com/docs/2.2/SQL-Match.html

    Try this

    match { class: host, as : host1, where: (hostname = "myhost") }
    .inE('link'){as: link}
    .outV(){as: host2}
    return host1.hostname,link.ports, host2.hostname