首页 > 解决方案 > 如何使这种类型的数据成为neo4j中的一个节点?

问题描述

我想从 json 数据在 neo4j 中创建一个节点,以用户名(唯一)命名,并具有 created_time(int) 和 info(a list) 作为专有

{
"ProfileInfo": {
    "created_time": 1286323200,
    "info": {
        "biography": "",
        "followers_count": 5000,
        "following_count": 1000,
        "full_name": "alpha beta",
        "id": 123456789,
        "is_business_account": true,
        "is_joined_recently": false,
        "is_private": false,
        "posts_count": 1,
    },
    "username": "alphabeta"
}

}

我试图在密码中运行这个命令:

Call apoc.load.json("file:/Neo4j/data/alpha_sample.json") YIELD value AS user
MERGE (u:USER {username:user.ProfileInfo.username})
SET u.created_time = user.ProfileInfo.created_time,
    u.info = user.ProfileInfo.info

但我得到这个错误,

Property values can only be of primitive types or arrays thereof

有谁知道我该怎么做?欢迎任何帮助

标签: graphneo4jcyphernodes

解决方案


您需要提取 ProfileInfo.username 中的每个元素。这样的事情有帮助吗?

CALL apoc.load.json("file:/Neo4j/data/alpha_sample.json") YIELD value AS user
MERGE (u:USER {username:user.ProfileInfo.username})
SET u.created_time = user.ProfileInfo.created_time,
    u += user.ProfileInfo.info

推荐阅读