gpt4 book ai didi

java - neo4j - 如何通过rest api运行1000个对象的查询

转载 作者:行者123 更新时间:2023-12-02 07:41:18 26 4
gpt4 key购买 nike

我需要运行 1000 个对象的查询。使用 /batch 端点我可以让它工作,但太慢(30 秒处理 300 个项目)。

所以我正在尝试与本文档页面中所述相同的方法:http://docs.neo4j.org/chunked/2.0.1/rest-api-cypher.html#rest-api-create-mutiple-nodes-with-properties

将此 JSON 发布到 http://localhost:7474/db/data/cypher

{
"params": {
"props": [
{
"_user_id": "177032492760",
"_user_name": "John"
},
{
"_user_id": "177032492760",
"_user_name": "Mike"
},
{
"_user_id": "100007496328",
"_user_name": "Wilber"
}
]
},
"query": "MERGE (user:People {id:{_user_id}}) SET user.id = {_user_id}, user.name = {_user_name} "
}

问题是我收到此错误:

{ message: 'Expected a parameter named _user_id',
exception: 'ParameterNotFoundException',
fullname: 'org.neo4j.cypher.ParameterNotFoundException',
stacktrace:
...

也许这仅适用于 CREATE 查询,如文档页面所示?

最佳答案

在 ON CREATE SET 中使用 FOREACH 和 MERGE:

 FOREACH (p in {props} | 
MERGE (user:People {id:{p._user_id}})
ON CREATE user.name = {p._user_name})

将此 JSON 发布到 http://localhost:7474/db/data/cypher

{
"params": {
"props": [
{
"_user_id": "177032492760",
"_user_name": "John"
},
{
"_user_id": "177032492760",
"_user_name": "Mike"
},
{
"_user_id": "100007496328",
"_user_name": "Wilber"
}
]
},
"query": "FOREACH (p in {props} | MERGE (user:People {id:{p._user_id}}) ON CREATE user.name = {p._user_name}) "
}

关于java - neo4j - 如何通过rest api运行1000个对象的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22799123/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com