Neo4j Traverser - Just get an item with specific type
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.fetchNextOr开发者_C百科Null(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)
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','')
Can you have a look at the data/log/*.log and data/messages.log file for possible stack-traces?
Thanks
精彩评论