Neo4j Traverser - 只需获取特定类型的项目
从任何给定的节点开始,我想运行遍历器,直到它到达具有“contentpage”类型的节点(所有节点都有类型属性)。
我已经用下面的遍历器尝试过,
{
"order":"depth first",
"uniqueness" : "node global",
"relationships":[
{"type":"CONTAINS","direction":"in"},
{"type":"HAS","direction":"in"}
],
"prune evaluator":{"language":"javascript","body":"position.endNode().getProperty('type')!='contentpage';"},
"max depth":10000000
}
但我得到的只是 HTTP-Error 500。 有什么想法吗?
编辑:这是一个堆栈跟踪(我对它进行了一些修剪,因为它很大)
Problem accessing /db/data/node/782350/traverse/node. Reason:
javax.script.ScriptException: sun.org.mozilla.javascript.WrappedException: Wrapped org.neo4j.graphdb.NotFoundException: type property not found for NodeImpl#782348. (<Unknown Source>#1) in <Unknown Source> at line number 1
Caused by:
org.neo4j.server.rest.domain.EvaluationException: javax.script.ScriptException: sun.org.mozilla.javascript.WrappedException: Wrapped org.neo4j.graphdb.NotFoundException: type property not found for NodeImpl#782348. (<Unknown Source>#1) in <Unknown Source> at line number 1
at org.neo4j.server.rest.domain.EvaluatorFactory$CompiledScriptExecutor.eval(EvaluatorFactory.java:183)
at org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedPruneEvaluator.pruneAfter(EvaluatorFactory.java:241)
at org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl$WrappedPruneEvaluator.evaluate(TraversalDescriptionImpl.java:239)
at org.neo4j.kernel.impl.traversal.MultiEvaluator.evaluate(MultiEvaluator.java:41)
at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.initialize(TraversalBranchImpl.java:93)
at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.next(TraversalBranchImpl.java:112)
at org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:50)
at org.neo4j.kernel.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:48)
at org.neo4j.kernel.impl.traversal.TraverserImpl$TraverserIterator.fetchNextOrNull(TraverserImpl.java:127)
at org.neo4j.kernel.impl.traversal.TraverserImpl$TraverserIterator.fetchNextOrNull(TraverserImpl.java:94)
at org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:55)
at org.neo4j.server.rest.web.DatabaseActions.traverse(DatabaseActions.java:922)
at org.neo4j.server.rest.web.RestfulGraphDatabase.traverse(RestfulGraphDatabase.java:641)
at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
Starting at any given Node I want to run the traverser till it hits a node which has "contentpage" as type (all nodes have a type-property).
I've tried it with the following traverser
{
"order":"depth first",
"uniqueness" : "node global",
"relationships":[
{"type":"CONTAINS","direction":"in"},
{"type":"HAS","direction":"in"}
],
"prune evaluator":{"language":"javascript","body":"position.endNode().getProperty('type')!='contentpage';"},
"max depth":10000000
}
But all I get is a HTTP-Error 500.
Any Ideas?
Edit: Here's a stack trace (I've trimmed it a bit because it was huge)
Problem accessing /db/data/node/782350/traverse/node. Reason:
javax.script.ScriptException: sun.org.mozilla.javascript.WrappedException: Wrapped org.neo4j.graphdb.NotFoundException: type property not found for NodeImpl#782348. (<Unknown Source>#1) in <Unknown Source> at line number 1
Caused by:
org.neo4j.server.rest.domain.EvaluationException: javax.script.ScriptException: sun.org.mozilla.javascript.WrappedException: Wrapped org.neo4j.graphdb.NotFoundException: type property not found for NodeImpl#782348. (<Unknown Source>#1) in <Unknown Source> at line number 1
at org.neo4j.server.rest.domain.EvaluatorFactory$CompiledScriptExecutor.eval(EvaluatorFactory.java:183)
at org.neo4j.server.rest.domain.EvaluatorFactory$ScriptedPruneEvaluator.pruneAfter(EvaluatorFactory.java:241)
at org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl$WrappedPruneEvaluator.evaluate(TraversalDescriptionImpl.java:239)
at org.neo4j.kernel.impl.traversal.MultiEvaluator.evaluate(MultiEvaluator.java:41)
at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.initialize(TraversalBranchImpl.java:93)
at org.neo4j.kernel.impl.traversal.TraversalBranchImpl.next(TraversalBranchImpl.java:112)
at org.neo4j.kernel.impl.traversal.StartNodeTraversalBranch.next(StartNodeTraversalBranch.java:50)
at org.neo4j.kernel.PreorderDepthFirstSelector.next(PreorderDepthFirstSelector.java:48)
at org.neo4j.kernel.impl.traversal.TraverserImpl$TraverserIterator.fetchNextOrNull(TraverserImpl.java:127)
at org.neo4j.kernel.impl.traversal.TraverserImpl$TraverserIterator.fetchNextOrNull(TraverserImpl.java:94)
at org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:55)
at org.neo4j.server.rest.web.DatabaseActions.traverse(DatabaseActions.java:922)
at org.neo4j.server.rest.web.RestfulGraphDatabase.traverse(RestfulGraphDatabase.java:641)
at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,似乎您应该具有
一般情况下,您不能发送空值。如果您想要默认值,请不要设置任何内容。请参阅此处了解更多信息:Neo4j REST API。
编辑更新的问题:
因此异常显示:
这是由以下原因引起的:
要避免这种情况,请为属性设置默认值,例如:
To begin with, it seems you should have
Generally, you can't send in nulls. Just don't set something if you want the default. Have a look here for more information: Neo4j REST API.
Edit for updated question:
So the exception says:
which is caused by:
To avoid this, set a default value for the the property, for example:
您可以查看 data/log/*.log 和 data/messages.log 文件以获取可能的堆栈跟踪吗?
谢谢
Can you have a look at the data/log/*.log and data/messages.log file for possible stack-traces?
Thanks