OrientDB 2.1.2: how to intersect between two result sets

519 views
Skip to first unread message

Markus Ritter

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

I have the following data structure:

Client
    -> users: List<User>
User
    -> emailAddresses: List<EmailAddress>
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!


user.w...@gmail.com

unread,
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.

Regards,
Michela

Luigi Dell'Aquila

unread,
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? 

Thanks

Luigi

--

---
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

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