OrientDB 2.1.2: how to intersect between two result sets

Skip to first unread message

Markus Ritter

Sep 18, 2015, 3:59:57 AM9/18/15
to orient-...@googlegroups.com
Hi @all,

I have the following data structure:

    -> users: List<User>
    -> emailAddresses: List<EmailAddress>
    -> email: String

Now I want to detect, if an email address is already included in a client if I add a new user to the client (e.g. client contains user 1 and user 2, user 1 contains email "te...@test.de", user 2 contains "te...@test.de", if I want to add user 3 containing also email "te...@test.de" I want to reject in my code).
So far I realized my query this way (#18:2 is a client, #12:1 is the new user to add, I just expand all existing email addresses from the client and want to get the union to all new users email addresses):

SELECT expand($c) LET $a = (SELECT expand(emailAddresses) FROM (SELECT expand(users) FROM #18:2)), $b = (SELECT expand(emailAddresses) FROM #12:1), $c = unionall($a, $b)

What I need is distinct($a, $b) or intersect, but both doesn´t work (at least in OrientDB 2.1.2) -> distinct() only allows for 1 field, intersect() throws:

java.lang.ClassCastException: com.orientechnologies.orient.core.sql.query.OResultSet cannot be cast to com.orientechnologies.common.util.OSupportsContains

So my question is: Is there an easier way to achieve such a check (also regarding performance of the query, because there might be a lot of users with email addresses per client) or do I face a bug of OrientDB or are there any other possible ways?

Thanks for you help!


Sep 21, 2015, 6:53:11 AM9/21/15
to OrientDB
Hi Markus,

I tried your query with the intersect command in 2.1.2 version and I have your same error, then I tried the same query as before with the previous version (2.1.1) and it works.


Luigi Dell'Aquila

Sep 21, 2015, 7:26:24 AM9/21/15
to orient-...@googlegroups.com
Hi Markus,

it seems a regression in 2.1.2, could you please open an issue about this? 




You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Markus Ritter

Sep 21, 2015, 10:24:22 AM9/21/15
to OrientDB
Reply all
Reply to author
0 new messages