这是在Cypher 1.8.2上
我有以下查询可以正常工作:
START person=node:personsindex('*:*')
WHERE person.name IN ['Peter', 'Michael']
RETURN person;
在 Java 中运行时,使用:
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
....
ExecutionEngine engine...
ExecutionResult result = this.engine.execute(query);
如果我的图表中确实有数据,我会得到结果:
assertEquals("Columns :", 1, result.columns().size());
Iterator<Node> personNodes = result.columnAs("person");
assertTrue("Should have some results", personNodes.hasNext())
如果我的查询变为:
START person=node:personsindex('*:*')
WHERE person.name IN 'Peter' // I know I should not do it like this
RETURN person;
我在 shell 上得到以下异常,这很好:
CypherTypeException: Literal expected to be of type Collection but it is of type String
但是当我在 Java 中运行它时,异常被吞没了,我得到了一个 columnSet,但没有数据:
ExecutionResult result = this.engine.execute(query);
assertEquals("Columns :", 1, result.columns().size());
Iterator<Node> personNodes = result.columnAs("person");
assertFalse("No results", personNodes.hasNext())
这是预期的行为吗?