neo4j REST 'Server got itself in trouble' - neo4j

I am running a very basic test to check my understanding and evaluate neo4j REST server (neo4j-community-1.8.M07). I am using Neo4j Python REST Client.
Each test iteration starts with a random strings for the source node name and the destination node name. The names contain only letters a..z and numbers 0..9 (oddly enough, I never got it to fail if I use A..Z and 0..9). The name may be from one char to 36 chars long and there are no repeating chars. I create 36 nodes, where the 1-st node name is only one char long and the 36-th node name has 36 chars. Then I create relations between all nodes. The name of each relation is the concatenation of the source node name and the destination node name. The final graph has 37 nodes (1 reference node and 36 nodes with names from one char to 36 non-repeating chars) and 1260 relations. Before each test iteration I clear the graph, so that it has only one (the reference) node.
The problem is that after several successful iterations neo4j REST server crashes:
Error [500]: Internal Server Error. Server got itself in trouble.
Invalid data sent
The query that crashes the system can be different - here is an example of a query_string that caused a problem:
START n_from=node:index_faqts(node_name="h"),
n_to=node:index_faqts(node_name="hg2b8wpj04ms")CREATE UNIQUE
n_from-[r:`hhg2b8wpj04ms` ]->n_to RETURN r
self.cypher_extension.execute_query( query_string )
I spent a lot of time trying to find a trend, but in vain. If I did something wrong with the queries none of the tests would ever work. I have observed crashes for number of successful test cycles between 5 and 25 rounds.
What might be causing neo4j REST server to crash?
P.S. Some details...
The nodes are created like this:
...
self.index_faqts[ "node_name" ][ p_str_node_name ] =
self.gdb.nodes.create( **p_dict_node_attributes )
...
Just in case - before issuing the query to create a new relation I check the graph to make sure that the
source and the destination nodes exist. That check never failed.

You are using too many relationship-types, currently the limit is at 32k. Might be patched in Neo4j if you have a valid use-case.

Related

Can I specify my own identifier ID as the relationship IDs in APOC.export?

Currently, it seems the relationship output by apoc.export function:
CALL apoc.export.csv.data( [], R, null, {stream:true}) YIELD data AS rdata
RETURN mdata, ndata, rdata
The format is:
_start _end _type
18701 19076 hasMember
The '18701' & '19076' are neo4j's internal ids. Can I use my own id from the node's identifier as the relationship connector? My own node identifier is always guaranteed to be unique. I want to periodically export KG nodes and relationships as KG grows overtime. In such a case, can the IDs always be unique among all nodes in the entire graph?
The possibility of getting duplicate nodes and relationships when using apoc.import.csv (even when ignoreDuplicateNodes is false, which is the default) is a known issue (see issues 1046 and 1048).
Unfortunately, issue 1048 was closed by its submitter even though is was not fixed.
You may want to open a new issue.

neo4j index failed immediately without error

NOTE this is not the same question Neo4j Index creation fails
We have 2 types of nodes in our DB which both have a string property called text. For node A this property is not unique and for node B this property is unique. (we never explicitly have any cypher code that creates any boundary/unique conditions on anything)
We want to have 2 indexes:
create index on :A(text)
create index on :B(text)
(i am currently running those cypher queries seperately from the browser interface)
the index on :B(text) takes a minute and works fine (4 million nodes), but the index on :A(text) (1 million nodes) fails immediately and eventhough i have also tried it with the python driver with the lowest debug level and looked through /var/log/neo4j/.. i can't find any indication as to why this is failing. Judging by the documentation the fact that :A(text) is not unique should not be a problem. Does anyone have hunch where something could be wrong?
EDIT:
Neo4j Version: 3.4.8
Longest :A(text) string: 17 chars (individual words)
Longest :B(text) string: 53 chars (short phrases)
EDIT: I realize fails immediately can be a bit of a vague term, so here exactly what happens when using the browser interface...
create index on :B(text)
returns
Added 1 index, completed after 1 ms.
immediately after
:schema
returns
Indexes
ON :B(text) POPULATING
after a while
:schema
returns
Indexes
ON :B(text) ONLINE
now for A
create index on :A(text)
returns
Added 1 index, completed after 1 ms.
immediately after
:schema
returns
Indexes
ON :B(text) ONLINE
ON :A(text) FAILED

How to concatenate three columns into one and obtain count of unique entries among them using Cypher neo4j?

I can query using Cypher in Neo4j from the Panama database the countries of three types of identity holders (I define that term) namely Entities (companies), officers (shareholders) and Intermediaries (middle companies) as three attributes/columns. Each column has single or double entries separated by colon (eg: British Virgin Islands;Russia). We want to concatenate the countries in these columns into a unique set of countries and hence obtain the count of the number of countries as new attribute.
For this, I tried the following code from my understanding of Cypher:
MATCH (BEZ2:Officer)-[:SHAREHOLDER_OF]->(BEZ1:Entity),(BEZ3:Intermediary)-[:INTERMEDIARY_OF]->(BEZ1:Entity)
WHERE BEZ1.address CONTAINS "Belize" AND
NOT ((BEZ1.countries="Belize" AND BEZ2.countries="Belize" AND BEZ3.countries="Belize") OR
(BEZ1.status IN ["Inactivated", "Dissolved shelf company", "Dissolved", "Discontinued", "Struck / Defunct / Deregistered", "Dead"]))
SET BEZ4.countries= (BEZ1.countries+","+BEZ2.countries+","+BEZ3.countries)
RETURN BEZ3.countries AS IntermediaryCountries, BEZ3.name AS
Intermediaryname, BEZ2.countries AS OfficerCountries , BEZ2.name AS
Officername, BEZ1.countries as EntityCountries, BEZ1.name AS Companyname,
BEZ1.address AS CompanyAddress,DISTINCT count(BEZ4.countries) AS NoofConnections
The relevant part is the SET statement in the 7th line and the DISTINCT count in the last line. The code shows error which makes no sense to me: Invalid input 'u': expected 'n/N'. I guess it means to use COLLECT probably but we tried that as well and it shows the error vice-versa'd between 'u' and 'n'. Please help us obtain the output that we want, it makes our job hell lot easy. Thanks in advance!
EDIT: Considering I didn't define variable as suggested by #Cybersam, I tried the command CREATE as following but it shows the error "Invalid input 'R':" for the command RETURN. This is unfathomable for me. Help really needed, thank you.
CODE 2:
MATCH (BEZ2:Officer)-[:SHAREHOLDER_OF]->(BEZ1:Entity),(BEZ3:Intermediary)-
[:INTERMEDIARY_OF]->(BEZ1:Entity)
WHERE BEZ1.address CONTAINS "Belize" AND
NOT ((BEZ1.countries="Belize" AND BEZ2.countries="Belize" AND
BEZ3.countries="Belize") OR
(BEZ1.status IN ["Inactivated", "Dissolved shelf company", "Dissolved",
"Discontinued", "Struck / Defunct / Deregistered", "Dead"]))
CREATE (p:Connections{countries:
split((BEZ1.countries+";"+BEZ2.countries+";"+BEZ3.countries),";")
RETURN BEZ3.countries AS IntermediaryCountries, BEZ3.name AS
Intermediaryname, BEZ2.countries AS OfficerCountries , BEZ2.name AS
Officername, BEZ1.countries as EntityCountries, BEZ1.name AS Companyname,
BEZ1.address AS CompanyAddress, AS TOTAL, collect (DISTINCT
COUNT(p.countries)) AS NumberofConnections
Lines 8 and 9 are the ones new and to be in examination.
First Query
You never defined the identifier BEZ4, so you cannot set a property on it.
Second Query (which should have been posted in a separate question):
You have several typos and a syntax error.
This query should not get an error (but you will have to determine if it does what you want):
MATCH (BEZ2:Officer)-[:SHAREHOLDER_OF]->(BEZ1:Entity),(BEZ3:Intermediary)- [:INTERMEDIARY_OF]->(BEZ1:Entity)
WHERE BEZ1.address CONTAINS "Belize" AND NOT ((BEZ1.countries="Belize" AND BEZ2.countries="Belize" AND BEZ3.countries="Belize") OR (BEZ1.status IN ["Inactivated", "Dissolved shelf company", "Dissolved", "Discontinued", "Struck / Defunct / Deregistered", "Dead"]))
CREATE (p:Connections {countries: split((BEZ1.countries+";"+BEZ2.countries+";"+BEZ3.countries), ";")})
RETURN BEZ3.countries AS IntermediaryCountries,
BEZ3.name AS Intermediaryname,
BEZ2.countries AS OfficerCountries ,
BEZ2.name AS Officername,
BEZ1.countries as EntityCountries,
BEZ1.name AS Companyname,
BEZ1.address AS CompanyAddress,
SIZE(p.countries) AS NumberofConnections;
Problems with the original:
The CREATE clause was missing a closing } and also a closing ).
The RETURN clause had a dangling AS TOTAL term.
collect (DISTINCT COUNT(p.countries)) was attempting to perform nested aggregation, which is not supported. In any case, even if it had worked, it probably would not have returned what you wanted. I suspect that you actually wanted the size of the p.countries collection, so that is what I used in my query.

Neo4j Cypher query fails and return with an Unknown Error

I'm trying to build a Cypher query to test if a specific structure exists so I can relate dates to it.
Running Neo4j 2.1.0-M01 on a Linux server, but the same issue occurred with Neo4j 2.0.1
We're starting with a clean database, 0 nodes.
First I'm running this MATCH query to prove that it runs.
Obviously this query is not going to return any nodes. But after creating the nodes, it will
fail with an 'unknown error'.
It seems like a bug to me, since a query with fewer nodes will return. Does anyone have suggestions how to rewrite this query for now?
Sorry for the large amount of code in this post.
Thanks,
-Edwin
Cypher Query:
MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'})
,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'})
,(sc1)-[:IS_PART_OF_CLUSTER]->(c)
,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'})
,(sc2)-[:IS_PART_OF_CLUSTER]->(c)
,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'})
,(sc3)-[:IS_PART_OF_CLUSTER]->(c)
,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'})
,(sc4)-[:IS_PART_OF_CLUSTER]->(c)
,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'})
,(sc5)-[:IS_PART_OF_CLUSTER]->(c)
,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'})
,(sc6)-[:IS_PART_OF_CLUSTER]->(c)
,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'})
,(sc7)-[:IS_PART_OF_CLUSTER]->(c)
,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'})
,(sc8)-[:IS_PART_OF_CLUSTER]->(c)
,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'})
,(sc9)-[:IS_PART_OF_CLUSTER]->(c)
,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'})
,(sc10)-[:IS_PART_OF_CLUSTER]->(c)
,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'})
,(sc11)-[:IS_PART_OF_CLUSTER]->(c)
,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'})
,(sc12)-[:IS_PART_OF_CLUSTER]->(c)
,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'})
,(sc13)-[:IS_PART_OF_CLUSTER]->(c)
,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'})
,(sc14)-[:IS_PART_OF_CLUSTER]->(c)
,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'})
,(sc15)-[:IS_PART_OF_CLUSTER]->(c)
,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'})
,(sc16)-[:IS_PART_OF_CLUSTER]->(c)
,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'})
,(sc17)-[:IS_PART_OF_CLUSTER]->(c)
,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'})
,(sc18)-[:IS_PART_OF_CLUSTER]->(c)
RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18
Rows returned: 0
Cypher Query for creating the nodes:
CREATE (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'})
,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'})
,(sc1)-[:IS_PART_OF_CLUSTER]->(c)
,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'})
,(sc2)-[:IS_PART_OF_CLUSTER]->(c)
,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'})
,(sc3)-[:IS_PART_OF_CLUSTER]->(c)
,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'})
,(sc4)-[:IS_PART_OF_CLUSTER]->(c)
,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'})
,(sc5)-[:IS_PART_OF_CLUSTER]->(c)
,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'})
,(sc6)-[:IS_PART_OF_CLUSTER]->(c)
,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'})
,(sc7)-[:IS_PART_OF_CLUSTER]->(c)
,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'})
,(sc8)-[:IS_PART_OF_CLUSTER]->(c)
,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'})
,(sc9)-[:IS_PART_OF_CLUSTER]->(c)
,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'})
,(sc10)-[:IS_PART_OF_CLUSTER]->(c)
,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'})
,(sc11)-[:IS_PART_OF_CLUSTER]->(c)
,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'})
,(sc12)-[:IS_PART_OF_CLUSTER]->(c)
,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'})
,(sc13)-[:IS_PART_OF_CLUSTER]->(c)
,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'})
,(sc14)-[:IS_PART_OF_CLUSTER]->(c)
,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'})
,(sc15)-[:IS_PART_OF_CLUSTER]->(c)
,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'})
,(sc16)-[:IS_PART_OF_CLUSTER]->(c)
,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'})
,(sc17)-[:IS_PART_OF_CLUSTER]->(c)
,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'})
,(sc18)-[:IS_PART_OF_CLUSTER]->(c)
RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18
19 nodes created, 18 relationships.
Now when I run the first query again, it takes one minute and will eventually return with 'Unknown error'.
Cypher Query:
MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'})
,(sc1:Controller{serialnumber:'7000610071',system_id:'1873784171',hostname:'node01',node_uuid:'7cd70205-66ae-11e0-a4a9-0deba859517d'})
,(sc1)-[:IS_PART_OF_CLUSTER]->(c)
,(sc2:Controller{serialnumber:'7000606111',system_id:'1873778118',hostname:'node02',node_uuid:'b954f0a1-6682-11e0-b8a0-517da924923d'})
,(sc2)-[:IS_PART_OF_CLUSTER]->(c)
,(sc3:Controller{serialnumber:'7000561878',system_id:'1873772083',hostname:'node03',node_uuid:'ac293586-6690-11e0-b8a0-517da924923d'})
,(sc3)-[:IS_PART_OF_CLUSTER]->(c)
,(sc4:Controller{serialnumber:'800000075807',system_id:'1873784143',hostname:'node04',node_uuid:'e8d6c7e5-663e-11e0-b8a0-517da924923d'})
,(sc4)-[:IS_PART_OF_CLUSTER]->(c)
,(sc5:Controller{serialnumber:'7000477261',system_id:'1873745662',hostname:'node05',node_uuid:'1d1ecc64-728c-11e0-bf0e-3d25383f7ed3'})
,(sc5)-[:IS_PART_OF_CLUSTER]->(c)
,(sc6:Controller{serialnumber:'7000477273',system_id:'1873745654',hostname:'node06',node_uuid:'140fb0f9-728c-11e0-afeb-49fcf0b6e6c3'})
,(sc6)-[:IS_PART_OF_CLUSTER]->(c)
,(sc7:Controller{serialnumber:'7000474908',system_id:'1873745665',hostname:'node07',node_uuid:'edbf9c62-728b-11e0-bf0e-3d25383f7ed3'})
,(sc7)-[:IS_PART_OF_CLUSTER]->(c)
,(sc8:Controller{serialnumber:'7000474910',system_id:'1873745695',hostname:'node08',node_uuid:'20dbfe67-7832-11e0-afeb-49fcf0b6e6c3'})
,(sc8)-[:IS_PART_OF_CLUSTER]->(c)
,(sc9:Controller{serialnumber:'7000609864',system_id:'1873802756',hostname:'node09',node_uuid:'a8b75397-6690-11e0-b8a0-517da924923d'})
,(sc9)-[:IS_PART_OF_CLUSTER]->(c)
,(sc10:Controller{serialnumber:'7000610021',system_id:'1873791030',hostname:'node10',node_uuid:'f6cf0705-6670-11e0-b8a0-517da924923d'})
,(sc10)-[:IS_PART_OF_CLUSTER]->(c)
,(sc11:Controller{serialnumber:'7000610057',system_id:'1873784128',hostname:'node11',node_uuid:'551b1bf8-663d-11e0-b8a0-517da924923d'})
,(sc11)-[:IS_PART_OF_CLUSTER]->(c)
,(sc12:Controller{serialnumber:'7000609981',system_id:'1873778164',hostname:'node12',node_uuid:'f6062d6c-663e-11e0-9b53-cd0ece6aa2ce'})
,(sc12)-[:IS_PART_OF_CLUSTER]->(c)
,(sc13:Controller{serialnumber:'7000610033',system_id:'1873778186',hostname:'node13',node_uuid:'ed0e61c5-6670-11e0-b07f-933da0385fdc'})
,(sc13)-[:IS_PART_OF_CLUSTER]->(c)
,(sc14:Controller{serialnumber:'7000610069',system_id:'1873784175',hostname:'node14',node_uuid:'8623ea28-66ae-11e0-ab9d-5fdc7f30dee7'})
,(sc14)-[:IS_PART_OF_CLUSTER]->(c)
,(sc15:Controller{serialnumber:'7000606109',system_id:'1873778197',hostname:'node15',node_uuid:'b4349a83-6682-11e0-ab9d-5fdc7f30dee7'})
,(sc15)-[:IS_PART_OF_CLUSTER]->(c)
,(sc16:Controller{serialnumber:'7000610045',system_id:'1873784157',hostname:'node16',node_uuid:'67d80db8-663d-11e0-9b53-cd0ece6aa2ce'})
,(sc16)-[:IS_PART_OF_CLUSTER]->(c)
,(sc17:Controller{serialnumber:'7001246085',system_id:'2014175904',hostname:'node19',node_uuid:'1c792588-ff4e-11db-94fe-3b91dd7dd242'})
,(sc17)-[:IS_PART_OF_CLUSTER]->(c)
,(sc18:Controller{serialnumber:'7001246097',system_id:'2014176797',hostname:'node20',node_uuid:'3ae9e7ae-ff44-11db-864d-af2af862bba3'})
,(sc18)-[:IS_PART_OF_CLUSTER]->(c)
RETURN c,sc1,sc2,sc3,sc4,sc5,sc6,sc7,sc8,sc9,sc10,sc11,sc12,sc13,sc14,sc15,sc16,sc17,sc18
Returns Unknown Error
Your MATCH query is way to complicated. There's no need to specify every node. The following query returns the cluster and its related controllers:
MATCH (c:Cluster{cluster_name:'mycluster',cluster_uuid:'7bd4f66d-5faf-11db-8d0d-000e0cba569c'})<-[:IS_PART_OF_CLUSTER]-(sc:Controller)
WITH c, collect(sc) as controllers
RETURN c as cluster, controllers

multiple loads in neo4j

I have loaded some data in neo4j graph database using batch importer. Now let's say if I have to load more data then do i have to keep track of what was inserted externally or there are standard features of neo4j that can be used to:
1) get the id for the last node inserted so that i know the id for the new node that needs to be inserted and index accordingly.
2) get the list of nodes already present in database so that i can check the uniqueness of the nodes that are going to be inserted. if a node already exists in the database i will just use the same id and won't create a new node.
3) check the uniqueness of the triplets - suppose a triplet "January Month is_a" is already present in neo4j database and let's say the new data that i want to insert also have same triplet, i would like to not insert it as it will give me duplicate results.
For example: if you add following data in neo4j graph database using batch-importer:https://github.com/jexp/batch-import
$ cat nodes.csv
name age works_on
Michael 37 neo4j
Selina 14
Rana 6
Selma 4
$ cat nodes_index.csv
0 name age works_on
1 Michael 37 neo4j
2 Selina 14
3 Rana 6
4 Selma 4
$ cat rels.csv
start end type since counter:int
1 2 FATHER_OF 1998-07-10 1
1 3 FATHER_OF 2007-09-15 2
1 4 FATHER_OF 2008-05-03 3
3 4 SISTER_OF 2008-05-03 5
2 3 SISTER_OF 2007-09-15 7
Now, if you have to add more data to the same database then you will need to know following things:
1) if nodes already exists then what are their ids so that you can use them while creating a triplet, if not then create a list of such nodes (not in database) and then start from a id that has not been used in last import and use it as a starting id for creating a new nodes_index.csv
2) if a triplet in database already exist, then don't create that triplet again as it will result in a duplicate result when running cypher queries against the database.
It seems like same issue has been raised here as well: https://github.com/jexp/batch-import/issues/27
Thanks!
1- why you need to know last node id .. you don't need to know the id to insert the new node it will added automatically in first free id in graph
2- for uniqueness , why you don't use create unique query "for nodes and relations as well"
here you can check the references : http://docs.neo4j.org/chunked/1.8/cypher-query-lang.html

Resources