I'm trying to run this query :
MERGE (pisrael:country {_id:'israel'})
MERGE (pisrael)-[:city]->(pisrael_pyafo:city {_id:'yafo'})
MERGE (pisrael_pyafo)-[:region]->(pisrael_pyafo_pbedfordshire:region {_id:'bedfordshire'})
MERGE (pisrael_pyafo_pbedfordshire)-[:street]->(pisrael_pyafo_pbedfordshire_phoppecircle:street {_id:'hoppecircle'})
MERGE (pisrael_pyafo)-[:region]->(pisrael_pyafo_pavon:region {_id:'avon'})
MERGE (pisrael_pyafo_pavon)-[:street]->(pisrael_pyafo_pavon_plaurycliff:street {_id:'laurycliff'})
MERGE (pisrael)-[:city]->(pisrael_phaifa:city {_id:'haifa'})
MERGE (pisrael_phaifa)-[:region]->(pisrael_phaifa_pavon:region {_id:'avon'})
MERGE (pisrael_phaifa_pavon)-[:street]->(pisrael_phaifa_pavon_pdougridges:street {_id:'dougridges'})
MERGE (pisrael_pyafo_pavon)-[:street]->(pisrael_pyafo_pavon_pdougridges:street {_id:'dougridges'})
MERGE (pisrael_pyafo_pbedfordshire)-[:street]->(pisrael_pyafo_pbedfordshire_ppercyneck:street {_id:'percyneck'})
MERGE (pisrael_phaifa_pavon)-[:street]->(pisrael_phaifa_pavon_plaurycliff:street {_id:'laurycliff'})
MERGE (pisrael_phaifa)-[:region]->(pisrael_phaifa_pbedfordshire:region {_id:'bedfordshire'})
MERGE (pisrael_phaifa_pbedfordshire)-[:street]->(pisrael_phaifa_pbedfordshire_phoppecircle:street {_id:'hoppecircle'})
MERGE (pisrael_phaifa_pavon)-[:street]->(pisrael_phaifa_pavon_ppercyneck:street {_id:'percyneck'})
MERGE (pisrael_pyafo_pbedfordshire)-[:street]->(pisrael_pyafo_pbedfordshire_pdougridges:street {_id:'dougridges'})
MERGE (pisrael_phaifa_pbedfordshire)-[:street]->(pisrael_phaifa_pbedfordshire_plaurycliff:street {_id:'laurycliff'})
MERGE (pisrael_phaifa_pbedfordshire)-[:street]->(pisrael_phaifa_pbedfordshire_ppercyneck:street {_id:'percyneck'})
MERGE (pisrael_phaifa_pavon)-[:street]->(pisrael_phaifa_pavon_phoppecircle:street {_id:'hoppecircle'})
MERGE (pisrael_pyafo_pavon)-[:street]->(pisrael_pyafo_pavon_ppercyneck:street {_id:'percyneck'})
MERGE (pisrael_pyafo_pavon)-[:street]->(pisrael_pyafo_pavon_phoppecircle:street {_id:'hoppecircle'})
WITH pisrael_pyafo_pbedfordshire_phoppecircle, pisrael_pyafo_pavon_plaurycliff, pisrael_phaifa_pavon_pdougridges, pisrael_pyafo_pavon_pdougridges, pisrael_pyafo_pbedfordshire_ppercyneck, pisrael_phaifa_pavon_plaurycliff, pisrael_phaifa_pbedfordshire_phoppecircle, pisrael_phaifa_pavon_ppercyneck, pisrael_pyafo_pbedfordshire_pdougridges, pisrael_phaifa_pbedfordshire_plaurycliff, pisrael_phaifa_pbedfordshire_ppercyneck, pisrael_phaifa_pavon_phoppecircle, pisrael_pyafo_pavon_ppercyneck, pisrael_pyafo_pavon_phoppecircle
MATCH (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c2:circle {_id:2})
MATCH (pisrael_phaifa_pavon_pdougridges_c2)-[:post]->(pisrael_phaifa_pavon_pdougridges_c2_p1:post {_id:1})
MATCH (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c19:circle {_id:19})
MATCH (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c15:circle {_id:15})
MATCH (pisrael_phaifa_pavon_pdougridges_c15)-[:post]->(pisrael_phaifa_pavon_pdougridges_c15_p2:post {_id:2})
MATCH (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c5:circle {_id:5})
MATCH (pisrael_phaifa_pavon_pdougridges_c5)-[:post]->(pisrael_phaifa_pavon_pdougridges_c5_p1:post {_id:1})
CREATE (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c22:circle {_id:22})
CREATE (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c23:circle {_id:23})
CREATE (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c24:circle {_id:24})
CREATE (pisrael_phaifa_pavon_pdougridges)-[:circle]->(pisrael_phaifa_pavon_pdougridges_c25:circle {_id:25})
SET pisrael_phaifa_pavon_pdougridges.circle_count=25
CREATE (pisrael_phaifa_pavon_pdougridges_c2_p1)-[:comment]->(pisrael_phaifa_pavon_pdougridges_c2_p1_c1:comment {_id:1})
SET pisrael_phaifa_pavon_pdougridges_c2_p1.comment_count=1
CREATE (pisrael_phaifa_pavon_pdougridges_c19)-[:post]->(pisrael_phaifa_pavon_pdougridges_c19_p1:post {_id:1})
SET pisrael_phaifa_pavon_pdougridges_c19.post_count=1
CREATE (pisrael_phaifa_pavon_pdougridges_c15_p2)-[:comment]->(pisrael_phaifa_pavon_pdougridges_c15_p2_c1:comment {_id:1})
CREATE (pisrael_phaifa_pavon_pdougridges_c15_p2)-[:comment]->(pisrael_phaifa_pavon_pdougridges_c15_p2_c2:comment {_id:2})
SET pisrael_phaifa_pavon_pdougridges_c15_p2.comment_count=2
CREATE (pisrael_phaifa_pavon_pdougridges_c5_p1)-[:comment]->(pisrael_phaifa_pavon_pdougridges_c5_p1_c2:comment {_id:2})
SET pisrael_phaifa_pavon_pdougridges_c5_p1.comment_count=2
WITH pisrael_pyafo_pbedfordshire_phoppecircle, pisrael_pyafo_pavon_plaurycliff, pisrael_pyafo_pavon_pdougridges, pisrael_pyafo_pbedfordshire_ppercyneck, pisrael_phaifa_pavon_plaurycliff, pisrael_phaifa_pbedfordshire_phoppecircle, pisrael_phaifa_pavon_ppercyneck, pisrael_pyafo_pbedfordshire_pdougridges, pisrael_phaifa_pbedfordshire_plaurycliff, pisrael_phaifa_pbedfordshire_ppercyneck, pisrael_phaifa_pavon_phoppecircle, pisrael_pyafo_pavon_ppercyneck, pisrael_pyafo_pavon_phoppecircle
MATCH (pisrael_phaifa_pavon_phoppecircle)-[:circle]->(pisrael_phaifa_pavon_phoppecircle_c2:circle {_id:2})
MATCH (pisrael_phaifa_pavon_phoppecircle_c2)-[:post]->(pisrael_phaifa_pavon_phoppecircle_c2_p1:post {_id:1})
CREATE (pisrael_phaifa_pavon_phoppecircle)-[:circle]->(pisrael_phaifa_pavon_phoppecircle_c10:circle {_id:10})
CREATE (pisrael_phaifa_pavon_phoppecircle)-[:circle]->(pisrael_phaifa_pavon_phoppecircle_c11:circle {_id:11})
CREATE (pisrael_phaifa_pavon_phoppecircle)-[:circle]->(pisrael_phaifa_pavon_phoppecircle_c12:circle {_id:12})
SET pisrael_phaifa_pavon_phoppecircle.circle_count=12
CREATE (pisrael_phaifa_pavon_phoppecircle_c2_p1)-[:comment]->(pisrael_phaifa_pavon_phoppecircle_c2_p1_c1:comment {_id:1})
SET pisrael_phaifa_pavon_phoppecircle_c2_p1.comment_count=1
WITH pisrael_pyafo_pbedfordshire_phoppecircle, pisrael_pyafo_pavon_plaurycliff, pisrael_pyafo_pavon_pdougridges, pisrael_pyafo_pbedfordshire_ppercyneck, pisrael_phaifa_pavon_plaurycliff, pisrael_phaifa_pbedfordshire_phoppecircle, pisrael_phaifa_pavon_ppercyneck, pisrael_pyafo_pbedfordshire_pdougridges, pisrael_phaifa_pbedfordshire_plaurycliff, pisrael_phaifa_pbedfordshire_ppercyneck, pisrael_pyafo_pavon_ppercyneck, pisrael_pyafo_pavon_phoppecircle
MATCH (pisrael_phaifa_pavon_plaurycliff)-[:circle]->(pisrael_phaifa_pavon_plaurycliff_c14:circle {_id:14})
MATCH (pisrael_phaifa_pavon_plaurycliff)-[:circle]->(pisrael_phaifa_pavon_plaurycliff_c2:circle {_id:2})
MATCH (pisrael_phaifa_pavon_plaurycliff_c2)-[:post]->(pisrael_phaifa_pavon_plaurycliff_c2_p1:post {_id:1})
MATCH (pisrael_phaifa_pavon_plaurycliff)-[:circle]->(pisrael_phaifa_pavon_plaurycliff_c3:circle {_id:3})
CREATE (pisrael_phaifa_pavon_plaurycliff)-[:circle]->(pisrael_phaifa_pavon_plaurycliff_c19:circle {_id:19})
SET pisrael_phaifa_pavon_plaurycliff.circle_count=19
CREATE (pisrael_phaifa_pavon_plaurycliff_c14)-[:post]->(pisrael_phaifa_pavon_plaurycliff_c14_p1:post {_id:1})
SET pisrael_phaifa_pavon_plaurycliff_c14.post_count=1
CREATE (pisrael_phaifa_pavon_plaurycliff_c2_p1)-[:comment]->(pisrael_phaifa_pavon_plaurycliff_c2_p1_c1:comment {_id:1})
SET pisrael_phaifa_pavon_plaurycliff_c2_p1.comment_count=1
CREATE (pisrael_phaifa_pavon_plaurycliff_c3)-[:post]->(pisrael_phaifa_pavon_plaurycliff_c3_p2:post {_id:2})
SET pisrael_phaifa_pavon_plaurycliff_c3.post_count=2
WITH pisrael_phaifa_pavon_ppercyneck
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c1:circle {_id:1})
MATCH (pisrael_phaifa_pavon_ppercyneck_c1)-[:post]->(pisrael_phaifa_pavon_ppercyneck_c1_p1:post {_id:1})
MATCH (pisrael_phaifa_pavon_ppercyneck_c1)-[:post]->(pisrael_phaifa_pavon_ppercyneck_c1_p3:post {_id:3})
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c5:circle {_id:5})
MATCH (pisrael_phaifa_pavon_ppercyneck_c5)-[:post]->(pisrael_phaifa_pavon_ppercyneck_c5_p2:post {_id:2})
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c8:circle {_id:8})
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c4:circle {_id:4})
MATCH (pisrael_phaifa_pavon_ppercyneck_c4)-[:post]->(pisrael_phaifa_pavon_ppercyneck_c4_p1:post {_id:1})
WITH pisrael_phaifa_pavon_ppercyneck
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c7:circle {_id:7})
MATCH (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c3:circle {_id:3})
MATCH (pisrael_phaifa_pavon_ppercyneck_c3)-[:post]->(pisrael_phaifa_pavon_ppercyneck_c3_p1:post {_id:1})
CREATE (pisrael_phaifa_pavon_ppercyneck)-[:circle]->(pisrael_phaifa_pavon_ppercyneck_c17:circle {_id:17})
but I keep getting this error:
Neo.DatabaseError.General.UnknownError: Found no solution for block with size 8,
Vector() were the selected candidates from the table IDPPlanTable(numberOfPlans=63, largestSolved=6)
You can try run it with EXPLAIN and you'll get the same error (if not then I think it is a bug or something)
Here is the opened issue in github:
https://github.com/neo4j/neo4j/issues/12212
UPDATE
I tried to run it on a better computer and it didn't give any errors, but I got the error when I tried with a bigger cypher.
Related
I am new to shell-scripting and Impala both, and want to create an automated script that will update my dynamic target table based on a fixed source table.
update tgt set tgt.$col1 = 'some value 1', tgt.$col2 = 'some value 2' from $target_table tgt
inner join source_table src on tgt.$col3 = src.col where 'some condition';
I can declare variables as $1,$2... for these dynamic attributes but the situation is like it will be like sometimes there is need to update just one column, so how to deal with this situation?
I need to execute the following query:
const query = `FOR u IN ${collection} FILTER ${filter} RETURN u`
so that filter variable is generated somehow by me (it is corrects, checked with Arango console)
But
db.query(query)
always returns empty cursor, and
db.query(aql`FOR u IN ${db.collection(collection)} FILTER ${filter} RETURN u`)
ignores my filter - data is not filtered.
How to execute query with arangojs with pre-generated filter?
Fix: db.query(query).all() worked
Can someone please help me with the exact syntax to use prepared insert / update statements containing map type columns.
suppose :
UPDATE abc SET map = map + ? where id = ?
where map is the map type column,
I found an answer
Cassandra prepared statements with collections
but it just contained the syntax to generate a particular map type object rather binding.
You need to execute it as usual for prepared queries, but you need to pass Cassandra::Map object as first parameter, something like this:
$statement = $session->prepare('....')
$map = Cassandra\Type::map(Cassandra\Type::varchar(), Cassandra\Type::int())
->create('a', 1);
$id = 'something'
$session->execute($statement, array('arguments' => array($map, $id)));
You need to pass Map object because CQL's appending to the map expects another map as an argument.
I am making a Node.js server which manipulates a Neo4j database. Now I have a system of admins and posts, admins add posts. This is currently what my graph looks like:
Now I want the network to be interconnected so I want to add a relationship between the Admin nodes "COLLEAGUE_OF". I wrote a Cypher query but I am getting a Cypher syntax error.
This is the syntax:
MERGE (c:Admin)
MERGE (n:BlogPost {mongoId:{idNeo}})
MERGE (b:Admin {mongoAdminId:{idNeoAd}})
MERGE(n)-[:ADDED_BY]->(b), (b)-[:COLLUEGE_OF]->(c)
This is the entire route which executes the syntax:
routes.post('/blogPosts/frontpage/:id/:aid', function (req, res) {
const id = req.param('id');
const aid = req.param('aid');
session
.run("MERGE (c:Admin) MERGE (n:BlogPost {mongoId:{idNeo}}) MERGE (b:Admin {mongoAdminId:{idNeoAd}}) MERGE(n)-[:ADDED_BY]->(b), (b)-[:COLLUEGE_OF]->(c)", {idNeo: id, idNeoAd: aid})
.then(function(result) {
res.status(200).json({"response": "BlogPost added to front page."});
session.close();
})
.catch((error) => {
res.status(400).json(error);
});
});
Assuming that :COLLUEGE_OF is the spelling you want (if this is in English, you may want :COLLEAGUE_OF instead), this query should take an existing graph of :Admin nodes and connect them to each other:
MATCH (c:Admin)
WITH collect(c) as admins
UNWIND admins as admin1
UNWIND admins as admin2
WITH admin1, admin2
WHERE id(admin1) < id(admin2) // prevents matching to the same pair with swapped order, and matching a node to itself
MERGE (admin1)-[:COLLUEGE_OF]-(admin2)
And this query would be used when adding a new blogpost and admin to the graph (it will not perform the merge if it has previously been processed):
MERGE (n:BlogPost {mongoId:{idNeo}})
MERGE (b:Admin {mongoAdminId:{idNeoAd}})
MERGE (n)-[:ADDED_BY]->(b)
WITH b
WHERE NOT (b)-[:COLLUEGE_OF]-()
MATCH (c:Admin)
WHERE c <> b
MERGE (b)-[:COLLUEGE_OF]-(c)
That said, if you really need :Admins to be connected to each other, it would be far easier to model this differently, with some kind of :ColleagueGroup node that all :Admins connect to, like this:
// create the single :ColleagueGroup node for all admins:
MERGE (group:ColleagueGroup)
WITH group
MATCH (c:Admin)
MERGE (c)-[:COLLUEGE_OF]->(group)
And then for adding a new admin
// add a new :Admin to the group
MERGE (n:BlogPost {mongoId:{idNeo}})
MERGE (b:Admin {mongoAdminId:{idNeoAd}})
WITH n, b
MATCH (group:ColleagueGroup)
MERGE (n)-[:ADDED_BY]->(b)
MERGE (b)-[:COLLUEGE_OF]->(group)
And for finding colleagues of a single :Admin node (which will be all :Admins):
MATCH (b:Admin {mongoAdminId:{idNeoAd}})-[:COLLUEGE_OF*2]-(colleague:Admin)
RETURN colleague
The problem is in the last line of your query, specifically, the , (b)-[:COLLUEGE_OF]->(c) statement, which creates a syntax error. Just remove the comma and add an additional merge statement.
MERGE (c:Admin)
MERGE (n:BlogPost {mongoId:{idNeo}})
MERGE (b:Admin {mongoAdminId:{idNeoAd}})
MERGE(n)-[:ADDED_BY]->(b)
MERGE(b)-[:COLLUEGE_OF]->(c)
I'm trying to populate two different QTableWidgets. For the first one it works find, but for the second one, it won't actaully set the items to the QTableWidget.
In the second, failing attempt, it does successfully create the item (both type(item) and item.text() work fine and return the correct values). However, when I try to add the item to the table, it says that table2.item(row, col) is NoneType. The rows and columns are created correctly before setting the item though.
working attempt:
item = QTableWidgetItem(self.fields[j].name())
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
table1.setItem(j,i,item)
failing attempt:
item = QTableWidgetItem(typ)
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
table2.setItem(row, col, item)
Neither can I see the difference between the two blocks, nor do I understand why it won't set the item to the TableWidget. Is there a geneal misunderstandng about how this works?