Property of a node not being displayed - neo4j

I created 2 nodes:
create
(g:gomma:composizione_chimica{tipo:'gomma'}),
(c:composizione_chimica{name:'composizione chimica'})
When I try to visualize in the graph frame the properties instead of ID by clicking the :composizione_chimica label, on the frame bottom there's only the {tipo}property available. So node g hate property "gomma" displayed, node c nothing. How can I fix this?

Unfortunately the web UI doesn't handle multiple labels ideally in situations like this.
If you just do a query for that one node like:
MATCH (c:composizione_chimica) WHERE c.name = 'composizione chimica' RETURN c
Then you should be able to choose the name.
Alternatively if you enter :style in the bar it will bring up a model where you can download a .grass file (a format made for Neo4j), edit it with your change locally, and then upload it again.

Can you plz explain what is your exact problem? As per I understand you have given same label :composizione_chimica to both node. So the node c which have label :composizione_chimica will only show you property {name:'composizione chimica'} and node g which have both label :gomma and :composizione_chimica will show you property {tipo:'gomma'}

Related

How to set text on the node in neo4j

I want to set the text on the node
I have a example,node is created,but it is bare in graph,only a circle without a text.
merge(n1 {label:'me'})
return n1
I expect a text on the node.
actually,result is like this:
bare node image
what I expected is:
node with text
I know I can creat a node with text like this:
MERGE (michael:Person { name: 'Michael Douglas' })
RETURN michael
Text will be Michael Douglas node with name
But if I change it to:
MERGE (michael:Person { name1: 'Michael Douglas' })
RETURN michael
No text! no text
or:
MERGE (michael:Event { name: 'Michael Douglas' })
RETURN michael
Text is a number 35 number text
So what is the principle of setting text?Why sometimes it will use the name of person,sometimes it is a number of internal id?sometimes it is bare?
Are there some rules?some document to tell?
Neo4j Browser comes with visual tool.
The fact that nodes displayed with different properties you see is just visual guide, completely unrelated to the Neo4j itself.
In the docs: Neo4j Browser Style Guide
The nodes will already have sensible captions assigned by the browser, which auto-selects a property from the property list to use as a caption. You can see all the properties of that element if you click on any node or relationship. Properties will appear below the visualization. Larger property sets might be collapsed into a subset, but there is a little triangle on the right to unfold them.
The Neo4j Browser will pick a "suitable" property to display. So it's usual to see name property is displayed but name1 is not.
To manually select a property to display:
Select the node (in the upper bar of the result view, not in the view)
Select the field you want to display as captions (in the lower bar)

Delphi, Master-Detail with DetailFields in the where condition (not in select-part)

I am using master-detail connection to show a list of assigned columns of a detail-table. In addition i want to show a second grid with not assigned detail columns
Example
Master-Table t_human: idHU, nameHU (like John, Oscar, ...)
Detail-Table t_property: idPO, namePO (like male, female, blond hair, beard, blue eyes ...)
Join-Table t_hu_po: idHU, idPO
-> John - male, blond hair
-> Oscar - male, blue eyes, beard
When i select a master table row i want to show the assigned porperties and also the not assigned ones. The master-detail for the assigned properties works fine.
But for the not-assigned properties doesn't work.
Detail-SQL:
select p.idPO, p.namePO
from t_property p
where not exists (select * from t_hu_po hp where hp.idHU = :idHU and hp.idPO = p.idPO)
Master-SQL:
select idHU, nameHU from human
When i try to select the detailfield in the delphi component (Devart, SDAC, TMSQuery) it only shows me the fields for p.idPO and p.namePO. The :idHU parameter in the statement is configured as parameter for the query in the component. When i manually type the idHU in the DetailFields property of the Dataset (TMSQuery) i get an Invalid column name 'idHU'.. from delphi when activating the query.
Does someone knows a better solution than doing it with events for datachange and manually setting the detail-parameter and refreshing the detail-query.
My thought was, that master-detail would do the same thing but only in background, so that i don't have do code it.
Thanks
Stephan
Instead of using the where not exists try where p.idPO not in (Select idPO from t_hu_po where idHU=:idHu)
By makinge the subquery simply return all the idPOs that exist for the selected idHu, your query now looks for the properties that are not in that list.

How to make Property as First property ( which is shown on node in Neo4j Browser)

I create a node with this cypher
MERGE (item:ITEM{code:'1629', price: 135000, url:'http://xuongmaythienphuc.vn/component/products/set-bo-dui-den-rot-vai-phoi-vien-logo-theu-sanh-dieu.html' })
On Neo4j Browser, price Property is first property and shown in the node in Visualization.
But I want to shown Code on visualization instead (1629 instead of 135000 for the example cypher).
click on the label above the viz
select the appropriate property below the viz as caption

Set degree of Nodes

I have a graph in which I am keeping the degree of a node as a property called "degree" in the node.
What I need is when I create an edge between two nodes, I need to increment the degree of the two nodes.
For creating unique edges I am using "CREATE UNIQUE" for the edges. So if I need to increment the property "degree" of the corresponding nodes, I need to use "ON CREATE" and "ON MATCH" as it is for "MERGE".
But I can't use the ON CREATE and ON MATCH with CREATE UNIQUE. So whats the proper way of using ON CREATE and ON MATCH with CREATE UNIQUE?
This is the way I am trying:
MATCH (n1:PER {Node_Id:"X"}), (n2:PER {Node_Id:"Y"}) WHERE n1.Node_Id<>n2.Node_Id CREATE UNIQUE (n1)-[r:PER_PER {Doc_Id:"st_new", Event_Class:"EC_1", Event_Instance:"EI_1"}]-(n2) ON CREATE SET n1.degree = n1.degree + 1, n2.degree = n2.degree + 1
Not sure why you want to store the degree as a property. Neo4j has a getDegree() function on API level, see http://neo4j.com/docs/stable/javadocs/org/neo4j/graphdb/Node.html#getDegree(). Cypher is not yet using this everywhere possible but for some patterns it already does.
Nevertheless to answer your question: just use MERGE instead of CREATE UNIQUE for eventually establishing the relationship:
MATCH (n1:PER {Node_Id:"X"}), (n2:PER {Node_Id:"Y"})
WHERE n1.Node_Id<>n2.Node_Id
MERGE (n1)-[r:PER_PER {Doc_Id:"st_new", Event_Class:"EC_1", Event_Instance:"EI_1"}]-(n2)
ON CREATE SET n1.degree = n1.degree + 1, n2.degree = n2.degree + 1
If you do have a good reason to store node degrees as a property, please have a look at one of our modules called RelCount, which has been build exactly for what you need to do. It is described in detail in my thesis.
However, as Stefan points out, have a go with getDegree() first and only if that isn't fast enough, or you need to get degree based on some relationship property values as well, use RelCount.

NEO4J WEB ADMIN INTERFACE SOME QUESTIONS

I apologize now for my bad English. I'm Italian
I'm just using Neo4j for the thesis, but I still have doubts about the multi use.
1) I have created from the web interface, two nodes. I realized that Neo4j has given these indices 0 and 1 (for research). Now suppose that I was wrong and I have to delete the node with index 1 .. Once deleted do I create a new one and the system puts index 2.
Practically now the first node with index 0 and the second node with index 2 But I want the second node still has index 1 (basically I want to use the index of the first, as I do?)
2) The same problem with the relationship between two nodes. if I'm wrong to create it, the gate and I create another, I lose the index of the one deleted.
3) If I have to create a relationship between 2 nodes with the double arrow, as I do.
I saw that every arrow must have a label, so if I create a relationship between 1 and 2, and a relationship between 2 and 1, you get the double arrow, but with two labels and does not suit me. Thank you for your help
sorry for my very bad English
You should really try to use your own IDs or unique identifier for your nodes, then you can disregard the internal node IDs all together.
If you begin with this Cypher statement in a new database (you only have to set it once),
CREATE CONSTRAINT ON (node:MyNodeLabel) ASSERT node.myid IS UNIQUE
then you can create nodes and relationship like this,
CREATE (a:MyNodeLabel { myid : 0 })
CREATE (b:MyNodeLabel { myid : 1 })
CREATE (a)-[r:RELTYPE]->(b)
or if you do not write the create statements in the same transaction,
CREATE (:MyNodeLabel { myid : 2 })
CREATE (:MyNodeLabel { myid : 3 })
then later,
MATCH (a:MyNodeLabel { myid : 2 }), (b:MyNodeLabel { myid : 3 })
CREATE (a)-[r:RELTYPE]->(b)
or create two nodes and a relationship at the same time
MERGE (:MyNodeLabel { myid : 4 })-[r:RELTYPE]->(:MyNodeLabel { myid : 5 })
You can of course change MyNodeLabel and myid to any identifier you like.
The problem you have with the relationship labels is purely visual or do I misunderstand you?
You know that you can traverse relationships in any direction so maybe you do not need two relationships?
Here is the documentation for Cypher if you have missed it, http://docs.neo4j.org/chunked/stable/.
ok. sorry. I return at home today.... Another question. when you create a relationship with a label on the arrow. how do sometime in the future to change the label
without delete the relationship? is possible?
Q ok. sorry. I return at home today.... Another question. when you create a relationship with a label on the arrow. how do sometime in the future to change the label without delete the relationship? is possible?
ANS Yes,
You can do that easily you can server for the node and remove label only from the node it will not impact the relation ship , but i will suggest you to assing another one if that was the only label on the node so you can group it properly.
match(n:User{Id:1})
remove n:User set n:DeletedUser
return n

Resources