通过Java访问neo4j节点和关系 [英] Access neo4j nodes and relationships through java

查看:1029
本文介绍了通过Java访问neo4j节点和关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经加载了5万个节点,并通过talend建立了它们之间的关系.我编写了Java代码以连接到neo4j并尝试执行密码查询.它正在连接neo4j,但显示错误的结果.我的Java代码是:

I have already loaded 50k nodes and established relationships between them through talend. I wrote java code to connect to neo4j and try to execute cypher query. It is connecting to neo4j but showing wrong results. My java code is:

package com.Neo4J;

import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;

public class CaseNeo4J {

private static final String Neo4J_DBPath="/neo4j-community-1.9.2/data/graph.db";
GraphDatabaseService gdb;

public void connect(){

    gdb = new GraphDatabaseFactory().newEmbeddedDatabase(Neo4J_DBPath);
    Transaction transaction = gdb.beginTx();
    ExecutionEngine engine = new ExecutionEngine(gdb);
    ExecutionResult result = engine.execute( "start n=node(*) return n");
    System.out.println(result.dumpToString());
}

public static void main(String[] args) {

    CaseNeo4J neoobj = new CaseNeo4J();
    neoobj.connect();

}
}

outputs as :
+-----------+
| n         |
+-----------+
| Node[0]{} |
+-----------+
1 row

实际上它应该显示50000个节点,但是它显示的只是1个...知道吗?

Actully it should show 50000 nodes but it is showing ony 1... Any idea?

推荐答案

对不起,如果我的主张太明显了,但是您是否尝试过使用:MATCH(n)RETURN n作为查询?

Sorry if my inswer is too obvious but have you tried with: MATCH(n) RETURN n as the query?

这篇关于通过Java访问neo4j节点和关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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