CypherQuery在JavaEmbedded中返回空结果,但在Neoclipse中返回正确的结果

时间:2013-04-25 09:11:06

标签: neo4j resultset cypher graph-databases

我遇到了一个密码查询的奇怪问题。查询在Neoclipse中正常工作并返回正确的结果。但是在java嵌入模式下,结果是空的。我无法弄清楚这个问题。 java嵌入式或类似的东西中是否有查询字符限制?

这是密码查询:

    START 
    typeNode6=node(6) ,
    containerNode=node(9) ,
    typeNode35=node(35) ,
    typeNode15=node(15) ,
    typeNode18=node(18) ,
    typeNode33=node(33) 
    MATCH (node6)-[:TYPE]->(typeNode6) ,
    (containerNode)-[:CONTAINS*]->(node6) ,
    (node35)-[:TYPE]->(typeNode35) ,
    (node6)-[:`http://www.test.test/types/s3/media#actors`]->(node35) ,
    (node15)-[:TYPE]->(typeNode15) , 
    (node35)-[:`http://www.test.test/types/s3/media#impersonatedBy`]->(node15) ,
    (node18)-[:TYPE]->(typeNode18) , 
    (node15)-[:`http://www.test.test/types/common#namedBy`]->(node18) ,
    (node33)-[:TYPE]->(typeNode33) , 
    (node6)-[:`http://www.test.test/types/s3/media#runtime`]->(node33)  
    WHERE 
    node6.`http://www.test.test/types/s3/media#releaseYear`! = 1988 
AND node18.`http://www.test.test/types/common#firstName`! = 'Robert' 
AND node18.`http://www.test.test/types/common#lastName`! = 'Davi' 
AND node33.`http://www.test.test/types/common#intValue`! = 131 RETURN node6";

这是我的java测试类:

@Test
    public void queryExecute() {
        ExecutionResult result, result2;
        ExecutionEngine engine;
        String query = "START typeNode6=node(6) ,containerNode=node(9) ,typeNode35=node(35) ,typeNode15=node(15) ,typeNode18=node(18) MATCH (node6)-[:TYPE]->(typeNode6) ,(containerNode)-[:CONTAINS*]->(node6) ,(node35)-[:TYPE]->(typeNode35) , (node6)-[:`http://www.test.test/types/s3/media#actors`]->(node35) ,(node15)-[:TYPE]->(typeNode15) , (node35)-[:`http://www.test.test/types/s3/media#impersonatedBy`]->(node15) ,(node18)-[:TYPE]->(typeNode18) , (node15)-[:`http://www.test.test/types/common#namedBy`]->(node18)  WHERE node18.`http://www.test.test/types/common#firstName`! = 'Robert' AND node18.`http://www.test.test/types/common#lastName`! = 'Davi' RETURN node6";
        String query2 = "START typeNode6=node(6) ,containerNode=node(9) ,typeNode35=node(35) ,typeNode15=node(15) ,typeNode18=node(18) ,typeNode33=node(33) MATCH (node6)-[:TYPE]->(typeNode6) ,(containerNode)-[:CONTAINS*]->(node6) ,(node35)-[:TYPE]->(typeNode35) , (node6)-[:`http://www.test.test/types/s3/media#actors`]->(node35) ,(node15)-[:TYPE]->(typeNode15) , (node35)-[:`http://www.test.test/types/s3/media#impersonatedBy`]->(node15) ,(node18)-[:TYPE]->(typeNode18) , (node15)-[:`http://www.test.test/types/common#namedBy`]->(node18) ,(node33)-[:TYPE]->(typeNode33) , (node6)-[:`http://www.test.test/types/s3/media#runtime`]->(node33)  WHERE node6.`http://www.test.test/types/s3/media#releaseYear`! = 1988 AND node18.`http://www.test.test/types/common#firstName`! = 'Robert' AND node18.`http://www.test.test/types/common#lastName`! = 'Davi' AND node33.`http://www.test.test/types/common#intValue`! = 131 RETURN node6";
        engine = new ExecutionEngine(svrInstance.getNeoGraphdb());
        result = engine.execute(query);
        result2 = engine.execute(query2);
        Assert.assertNotNull(result);

        System.out.println("============== CYPHER QUERY TEST ==============");
        System.out.println("uncomplicated: ");
        System.out.println(result.toString());
        System.out.println("complicated: ");
        System.out.println(result2.toString());
        System.out.println("============== CYPHER QUERY TEST ==============");

    }

这是java控制台的输出:

============== CYPHER QUERY TEST ==============
uncomplicated: 
+---------------------------------------------------------------------------------------------------------------------------------------------------+
| node6                                                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------+
| Node[7]{http://www.test.test/types/common#id:"movie_1",http://www.test.test/types/s3/media#releaseYear:1988,type:"instance",instanceId:"movie_1"} |
+---------------------------------------------------------------------------------------------------------------------------------------------------+
1 row
138 ms

complicated: 
+-------+
| node6 |
+-------+
+-------+
0 row
4 ms

============== CYPHER QUERY TEST ==============

两个查询(在java中)应该返回相同的结果(至少在Neoclipse中)。不同的是,“复杂的查询”得到了更多的“WHERE”条件。

顺便说一下,查询是从java动态生成的,但这不应该是问题,因为它们在Neoclipse中工作。 (而且我总是使用相同的数据库位置。)

感谢您的帮助! 问候Max

1 个答案:

答案 0 :(得分:0)

所以,我可以理解,两个查询都可以正常使用Neo4jServer版本1.7.2。 版本1.8.2必须出错!