I have a requirement in which a property key can contain multiple values. How do I store them as property in Neo4j?
Ex: Person node has properties like: 'name', 'age' and 'interests' The 'interests' property can can contain more than one strings(array of strings).
What is the best approach to store 'interests'? I think I don't want to complicate this by adding more nodes. Instead I want to keep all properties in the same Person node.
Also, it will be good if I can search a Person node by any one item in the 'interests' property.
Store as one string separated by some special chars? Store as array of strings for a property? if so how do I do this?
Thanks
In Neo4j, properties are the key-value pairs which are used by nodes to store data. CREATE statement is used to create node with properties, you just have to specify these properties separated by commas within the curly braces "{ }". Syntax: CREATE (node:label { key1: value, key2: value, . . . . . . . . . })
Property types. Integer, Float, String, Boolean, Point, Date, Time, LocalTime, DateTime, LocalDateTime, and Duration.
A graph key is a property or set of properties which help you to identify a node or relationship in a graph. They are frequently used as a starting point for a graph traversal, or used as a condition to constrain.
Return all elements When you want to return all nodes, relationships and paths found in a query, you can use the * symbol. Node[0]{name:"A",age:55,happy:"Yes!"}
You can store an array of strings as a property and that's what I might suggest if you want to simply see a list of interests when working with a particular Person
node:
http://neo4j.com/docs/stable/rest-api-property-values.html#_arrays
If you want to look up people by interests, however, I would strongly suggest thinking about storing them as nodes. With the MERGE
cypher command it can be quite easy to manage them, and it should be more performant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With