例如,如果我在事务中创建了两个节点
node1 = db.graphDb.createNode();
node2 = db.graphDb.createNode();
// index user id
node1.setProperty("abc", "fkdjasflasdjlf");
db.nodeIndex.add(node1, "abc", "fkdjasflasdjlf");
node1 具有属性“abc”,但 node2 没有。
然后我尝试查询节点,比如列出所有具有属性“abc”等于“fkdjasflasdjlf”的节点。
ExecutionResult result = engine.execute("START n=node(*) WHERE n.abc = 'fkdjasflasdjlf' return n ");
Neo4j 生成异常
Exception in thread "main" org.neo4j.cypher.EntityNotFoundException: The property 'abc' does not exist on Node[0]
at org.neo4j.cypher.internal.commands.expressions.Property.apply(Property.scala:35)
at org.neo4j.cypher.internal.commands.expressions.Property.apply(Property.scala:29)
at org.neo4j.cypher.internal.commands.Equals.isMatch(ComparablePredicate.scala:60)
at org.neo4j.cypher.internal.pipes.FilterPipe$$anonfun$createResults$1.apply(FilterPipe.scala:29)
at org.neo4j.cypher.internal.pipes.FilterPipe$$anonfun$createResults$1.apply(FilterPipe.scala:29)
at scala.collection.Iterator$$anon$22.hasNext(Iterator.scala:390)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:138)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.JavaConversions$IteratorWrapper.hasNext(JavaConversions.scala:562)
at neo4j.TestNodeSearch.main(TestNodeSearch.java:59)
Caused by: org.neo4j.graphdb.NotFoundException: 'abc' property not found for NodeImpl#0.
at
org.neo4j.kernel.impl.core.Primitive.newPropertyNotFoundException(Primitive.java:184)
at org.neo4j.kernel.impl.core.Primitive.getProperty(Primitive.java:179)
at org.neo4j.kernel.impl.core.NodeImpl.getProperty(NodeImpl.java:52)
at org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:155)
at org.neo4j.cypher.internal.commands.expressions.Property.apply(Property.scala:33)
那么有没有办法支持“不同类型”的节点,或者目前只支持一种类型的节点?
非常感谢!