Neo4j Traverser - 只需获得特定类型的物品

时间:2011-06-20 07:59:23

标签: java neo4j traversal

从任何给定节点开始我想运行遍历器,直到它遇到一个“contentpage”为类型的节点(所有节点都有一个type-property)。

我已尝试使用以下遍历

{
    "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)

2 个答案:

答案 0 :(得分:2)

首先,您似乎应该

 "uniqueness" : "node global"

通常,您不能发送空值。如果您想要默认设置,请不要设置。请点击此处了解更多信息:Neo4j REST API

修改以获取更新的问题:

所以例外说:

NotFoundException: type property not found for NodeImpl

由以下原因引起:

position.endNode().getProperty('type')

要避免这种情况,请为属性设置默认值,例如:

getProperty('type','')

答案 1 :(得分:0)

您可以查看data / log / * .log和data / messages.log文件以获取可能的堆栈跟踪吗?

由于