user15715772
user15715772

Reputation: 1

How to save multiple labels of a node in neo4j in a specified order?

I use py2neo to create a node, which has three labels ('photograph', 'creativework', 'thing'), and stores them in neo4j in the order of those labels. In the follow-up work, I will use the first label, which is'photograph'.

But the order in which the label of the node is displayed in neo4j is as follows:

enter image description here

And the order of the nodes retrieved by py2neo is also wrong, the first label becomes 'creativework', which is not to my liking. So how to save multiple labels of a node in neo4j in a specified order?

Upvotes: 0

Views: 182

Answers (1)

David A Stumpf
David A Stumpf

Reputation: 793

Can you clarify the problem? There are times when analytics or visualizations benefit from multiple labels. I'm making some assumption by creating the framework (which you should do in future questions). Is this your scenario? I've added another Label "Node"

create (n1:Node)
create (n2:Node)
create (n3:Node)

with n1,n2,n3
match (n1) set n1:CreativeWork 
with n1,n2,n3
match (n1) set n1:ImageProject 
with n1,n2,n3
with n1,n2,n3
match (n1) set n1:MediaProject 
with n1,n2,n3
match (n1) set n1:Thing 

with n1,n2,n3
match (n2) set n1:CreativeWork 
with n1,n2,n3
match (n2) set n1:ImageProject 
with n1,n2,n3
match (n2) set n1:MediaProject 
with n1,n2,n3
match (n2) set n1:Thing 

with n1,n2,n3
match (n3) set n1:CreativeWork 
with n1,n2,n3
match (n3) set n1:MediaProject 

If so, what is it you're trying to do. The display you showed is the node labels are they would appear in the results window after running a query.There is not a way to change that sort order. But why is that sort important to you? It's not something an end user will see. You actually have only 3 nodes and they would all be visualized similarly.

Can you achieve you goal using properties? If not every node has 3Labels, then you could use a grass file to distinguish them. The grass file processes the formatting by the order (bottom to top) the nodes appear in the listing.

Upvotes: 0

Related Questions