Neo4j Traverser - 只需获取特定类型的项目

发布于 2024-11-16 03:19:32 字数 2670 浏览 3 评论 0原文

从任何给定的节点开始,我想运行遍历器,直到它到达具有“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东北女汉子 2024-11-23 03:19:32

首先,似乎您应该具有

 "uniqueness" : "node global"

一般情况下,您不能发送空值。如果您想要默认值,请不要设置任何内容。请参阅此处了解更多信息:Neo4j REST API

编辑更新的问题:

因此异常显示:

NotFoundException: type property not found for NodeImpl

这是由以下原因引起的:

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

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

getProperty('type','')

To begin with, it seems you should have

 "uniqueness" : "node global"

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:

NotFoundException: type property not found for NodeImpl

which is caused by:

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

To avoid this, set a default value for the the property, for example:

getProperty('type','')
楠木可依 2024-11-23 03:19:32

您可以查看 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文