I just wanted to quickly chime in here as there seems to be a max limit 
(although, I don't know what that is but it seems to be based on memory 
allocation) to creating relationships in bulk.
Graph DB node counts:
Contact nodes: 42k
ContactMembership nodes: 52k
ContactMembershipType nodes: 6k

When I try the following query the system errors out with "Unknown Error":


*MATCH (s:ContactMembership), *
*(contact:Contact {ContactId : s.ContactId}) , *
*(contactmembershiptype:ContactMembershipType {ContactMembershipTypeId : 
s.ContactMembershipTypeId})*

*MERGE (contact)-[:CONTACT_CONTACTMEMBERSHIPTYPE {ContactId : s.ContactId, 
ContactMembershipTypeId : 
s.ContactMembershipTypeId}]->(contactmembershiptype)*


However, the same query works when I do Contacts and Addresses.
Contacts: 42k
Addresses: 50k
ContactAddresses: 50k

*MATCH (s:ContactAddress), *
*(contact:Contact {ContactId : s.ContactId}) , *
*(address:Address {AddressId : s.AddressId})*

*MERGE (contact)-[:CONTACT_ADDRESS {ContactId : s.ContactId, **AddressId** : 
s.** AddressId**}]->(**address**)*


I'm not sure if this is a memory allocation issue or not.  I posted a 
question on StackOverflow about this.
http://stackoverflow.com/questions/22030382/neo4j-2-0-matching-nodes-in-a-matrix-to-create-relationships-errors-out
And one about memory not being allocated anymore after multiple service 
restarts:
http://stackoverflow.com/questions/22040909/neo4j-2-0-windows-memory-stops-being-allocated-to-service-after-a-few-service-r


On Monday, November 18, 2013 8:25:06 AM UTC-5, Gleb Chermennov wrote:
>
> I experimented a bit more and came up with this version of your query:
> MERGE (a:User { Id:1 })
> MERGE (d:User { Id:2 })
> MERGE (b:User { Id:100 })
> MERGE (c:User { Id:101 })
> CREATE UNIQUE (a)-[:FRIEND]->(b), (c)-[:FRIEND]->(d)
>
> It can be, I guess, extended to support fairly large number of 
> nodes/relationships. 
> Thanks for your help, appreciate it.
>
> понедельник, 18 ноября 2013 г., 17:15:20 UTC+4 пользователь Gleb 
> Chermennov написал:
>>
>> oh, my mistake - I didn't say it explicitly, but I need to create 
>> multiple relationships at once, but it may not necessarily be the same 
>> nodes (i.e. not two-way relation between nodes a and b, but relation 
>> between b and c, b and d, e and f, etc.)
>>
>> понедельник, 18 ноября 2013 г., 15:42:38 UTC+4 пользователь Nigel Small 
>> написал:
>>>
>>> Then I'm not sure I understand your use case. I thought you wanted to be 
>>> able to execute multiple CREATE UNIQUE clauses in one statement.
>>>
>>>
>>> On 18 November 2013 11:38, Gleb Chermennov <[email protected]> wrote:
>>>
>>>> but if I can only do exact comparison (i.e. on node properties), that 
>>>> doesn't sound very good. 
>>>>
>>>> понедельник, 18 ноября 2013 г., 15:33:34 UTC+4 пользователь Nigel Small 
>>>> написал:
>>>>>
>>>>> Yes, I just gave a small example. You can have as many as you like.
>>>>>
>>>>>
>>>>> On 18 November 2013 11:11, Gleb Chermennov <[email protected]>wrote:
>>>>>
>>>>>> Can this query be applied to more than 2 nodes?
>>>>>>
>>>>>> понедельник, 18 ноября 2013 г., 14:54:59 UTC+4 пользователь Nigel 
>>>>>> Small написал:
>>>>>>>
>>>>>>> You can include multiple CREATE UNIQUE statements within a single 
>>>>>>> query, something like this:
>>>>>>>
>>>>>>> MERGE (a:Person { name:'Alice' })
>>>>>>> MERGE (b:Person { name:'Bob' })
>>>>>>> CREATE UNIQUE (a)-[:KNOWS]->(b)
>>>>>>> CREATE UNIQUE (b)-[:KNOWS]->(a)
>>>>>>>
>>>>>>> Nige
>>>>>>>
>>>>>>>
>>>>>>> On 18 November 2013 10:49, Gleb Chermennov <[email protected]>wrote:
>>>>>>>
>>>>>>>> I'm trying to create multiple relationships at once, using CREATE 
>>>>>>>> UNIQUE clause (I was advised to stick with Cypher query).
>>>>>>>> Is that scenario possible at all? Coudn't find an answer in google 
>>>>>>>> or in docs.
>>>>>>>> I'm importing a sql database, so creating relationships one by one 
>>>>>>>> is not an option for me.
>>>>>>>> My initial attempt was this query:
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right ORDER BY 1 SKIP 0 LIMIT 1 RETURN left, right
>>>>>>>> UNION
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right ORDER BY 1 SKIP 3 LIMIT 1 RETURN left, right 
>>>>>>>> UNION
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right ORDER BY 1 SKIP 6 LIMIT 1 RETURN left, right 
>>>>>>>> CREATE UNIQUE left-[rel:FRIEND]->right RETURN rel;
>>>>>>>> The idea is, I'm assembling a dataset of nodes I want to connect, 
>>>>>>>> then creating relationships between them.
>>>>>>>> This query doesn't work because there can't be multiple results 
>>>>>>>> statements.
>>>>>>>> Then I tried another query:
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right LIMIT 1 UNION
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right SKIP 4 LIMIT 1 UNION
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right SKIP 8 LIMIT 1 
>>>>>>>> CREATE UNIQUE left-[rel:FRIEND]->right RETURN rel;
>>>>>>>> but that doesn't work either (query analyser throws an error).
>>>>>>>> My final approach was this (same as number 2 but without unions):
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right LIMIT 1
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right SKIP 4 LIMIT 1
>>>>>>>> MATCH left, right WHERE (ID(right) IN [1, 2, 3] AND ID(left) IN [4, 
>>>>>>>> 5, 6]) WITH left, right SKIP 8 LIMIT 1 
>>>>>>>> CREATE UNIQUE left-[rel:FRIEND]->right RETURN rel;
>>>>>>>> but that just returns 0 rows - so it doesn't work as well.
>>>>>>>> Any suggestions? There's something I'm doing wrong here, obviously.
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "Neo4j" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to [email protected].
>>>>>>>>
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>
>>>>>>>
>>>>>>>  -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "Neo4j" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Neo4j" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to