使用 REST GraphDb 时 Cypher neo4j 结果缓慢
我正在使用 neo4j-rest-graphdb,刚刚尝试使用 Cypher 来获取简单的 Node 结果。
CypherParser parser = new CypherParser();
ExecutionEngine engine = new ExecutionEngine(graphDbService);
Query query = parser.parse( "START referenceNode = node (0) " +
"MATCH referenceNode-[PRODUCTS_REFERENCE]->products-[PRODUCT]->product " +
"RETURN product.productName " +
"ORDER BY product.productId " +
"SKIP 20"
"LIMIT 10");
ExecutionResult result = engine.execute( query );
Iterator<Map<String, Object>> iterator = result.javaIterator();
迭代结果的最佳实践是什么?最后一行导致我的服务挂起约 6 秒。如果最后没有迭代器,应用程序会非常快速。我还尝试了 webadmin 密码终端,结果在 50 毫秒内获取。我做错了什么吗?
I am working with the neo4j-rest-graphdb an just tried to use Cypher for fetching a simple Node result.
CypherParser parser = new CypherParser();
ExecutionEngine engine = new ExecutionEngine(graphDbService);
Query query = parser.parse( "START referenceNode = node (0) " +
"MATCH referenceNode-[PRODUCTS_REFERENCE]->products-[PRODUCT]->product " +
"RETURN product.productName " +
"ORDER BY product.productId " +
"SKIP 20"
"LIMIT 10");
ExecutionResult result = engine.execute( query );
Iterator<Map<String, Object>> iterator = result.javaIterator();
What is the best practise to iterate through the result? The last line causes my service to hang for ~6 sec. Without the iterator at the end the application is quiet fast. I also tried the webadmin cypher terminal, the results are fetched within 50ms. Am i doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在你的情况下,所有的密码操作(图形匹配、过滤等都会通过网络进行,这非常繁琐且缓慢),你不希望这样!
neo4j-rest-graphdb 支持远程执行开箱即用的 cypher:
只需执行此操作即可 测试用例:
In your case all the cypher operations (graph-matching, filtering etc. would go over the wire which is awfully chatty and slow) you don't want that !
The neo4j-rest-graphdb supports remote execution of cypher out of the box:
Just do, something like shown in this testcase:
如果我理解正确的话,graphDbService 是一个 REST 图形数据库,对吗?
如果您想在服务器上使用 Cypher,则应该使用 CypherPlugin。看这里:http://docs.neo4j.org/chunked/snapshot/cypher- plugin.html
我希望这有帮助,
安德烈斯
If I understood you correctly, graphDbService is a REST graph database, correct?
If you want to use Cypher on the Server, you should instead use the CypherPlugin. Look here: http://docs.neo4j.org/chunked/snapshot/cypher-plugin.html
I hope this helps,
Andrés