Frage

I have seen some similar questions on SO but none of the answers have worked for me yet, so I am hoping to get a new answer with the new features that have been added to recent versions of OrientDb since the other questions were asked.

I am trying to query all vertices which have an outgoing edge of a particular type but no outgoing edge of another type.

As an example in a simple relationship of

Person ---- Friend ---> Person

Person ---- Owns ---> Car

I am trying to find all the persons who have friends but do not own a car.

I have already tried the following query with no luck (It returns all the persons irrespective of whether or not those vertices have an outgoing edge of a particular kind)

select from Person where (out('Friend') not null and out('Owns').size() = 0)
select from Person where (out('Friend') is not null and out('Owns') is null)

In my efforts I realized that the NOT query is not supported yet by OrientDb in the WHERE clause as per this page: https://github.com/orientechnologies/orientdb/wiki/SQL-Where Can someone please verify if this is indeed true.

Anyways, I moved on and tried to simplify my query and tried to find only vertices that do not have the outgoing edge of 'Owns'. Even that did not work in that it seemed to return all the Person vertices in my graph:

select from Person where (out('Owns').size() = 0)
select from Person where (out('Owns') is null)

Not sure what I am missing, but any help is as always greatly appreciated.

War es hilfreich?

Lösung

Try working always with size, like this:

select from Person where outE('Friend').size() > 0 and outE('Owns').size() = 0

Andere Tipps

however, my queries return differently select from customer where outE('email').size() > 0; 0 items

select from customer where outE('email') is not NULL; many items returned

looks to me "size() > 0" is not the same as "is not NULL"

sorry if I am wrong

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top