如何在Neo4j中向属性添加多个值 [英] How to add multiple values to a property in neo4j

查看:1545
本文介绍了如何在Neo4j中向属性添加多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是neo4j的新手,正在尝试将多个值添加到节点的属性中.

I am new to neo4j and trying to add multiple values to a property of a node.How to do it?

 create (e:Employee{name:"Sam",languages:["C","C#"]})

对此进行了尝试,但没有找到向属性添加多个值的任何适当方法.

Tried this but didn't find any proper way to add multiple values to an attribute.

推荐答案

实际上,您可以在属性中包含数组值.您应该能够像这样创建它们:

In fact, you can have array values in properties. You should be able to create them like:

CREATE (n:Node { color: ['Red', 'Blue']})
RETURN n

在您的情况下:

CREATE (e:Employee { name:"Sam",languages: ["C", "C#"]})
RETURN e

工作正常(您可以在 http://console.neo4j.org/中进行检查)

is working perfectly fine (you can check it in http://console.neo4j.org/)

请记住,数组中的所有值都必须具有相同的类型,只有字符串或整数等.您可以在此处找到更多信息->

Keep in mind that all values in the array must be of the same type, only Strings, or Integers, etc. You can find more info here -> http://neo4j.com/docs/stable/rest-api-property-values.html

但是,考虑到CC#Sam知道的语言,这并不是该示例的最佳方法,应该通过某种Knows关系将它们作为Sam指向的不同节点

However that's not the best approach for that particular example given that C and C# are languages that Sam knows, you should have them as different nodes pointed by Sam through some kind of Knows relationship.

这篇关于如何在Neo4j中向属性添加多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆