Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-25-2021 09:00 AM
Is it possible for properties of a relationship to have their own properties? I am using people as a relationship between my nodes, and each person has their own properties (name, height, etc.). Between each node, there are many people/edges. I was wondering, could I have all these people in a single relationship as properties and each property (person) having their own properties? So I could search for relationship.person.name or something of that sort?
Solved! Go to Solution.
04-28-2021 12:59 PM
If you're referring to map properties, or more complex structures as properties, that's not currently possible.
For structures as properties, we only support simple lists. You cannot use lists of maps, or lists of other lists, and you can't use maps as properties.
You can turn such structures into JSON strings, which you can save as properties instead (since they're just strings), but in order to explore the structure, you would need to project them out and transform them from JSON strings back to structures first.
There are some convert functions in APOC Procedures that can help:
apoc.convert.toJson()
apoc.convert.fromJsonList()
apoc.convert.fromJsonMap()
04-25-2021 03:59 PM
It is possible.
However, I don't think it is a good graph design.
For example, if the name changes, you would need to rename the relationship or add a new one.
Then, if you are looking for people over a certain height, it would be better to have a relationship that does not include person names.
04-25-2021 04:21 PM
Hello @koji
Thank you for the reply! How would it be possible? Why would it be bad to have relationships include name if I am searching by height, the relationships I already have include both of those properties anyways? Also, would it then be better graph design to leave each person as their own edge? Sorry for all the questions, I am new to graph databases.
04-25-2021 05:32 PM
This is good blog about the Dark Side.
04-28-2021 12:59 PM
If you're referring to map properties, or more complex structures as properties, that's not currently possible.
For structures as properties, we only support simple lists. You cannot use lists of maps, or lists of other lists, and you can't use maps as properties.
You can turn such structures into JSON strings, which you can save as properties instead (since they're just strings), but in order to explore the structure, you would need to project them out and transform them from JSON strings back to structures first.
There are some convert functions in APOC Procedures that can help:
apoc.convert.toJson()
apoc.convert.fromJsonList()
apoc.convert.fromJsonMap()
All the sessions of the conference are now available online