Emil,
there are some good docs at
http://docs.neo4j.org/chunked/snapshot/tutorials-java-embedded-traversal.html#_new_traversal_frameworkthat
you can use.

In your case, you are stopping the traversal but not excluding the nodes
you find from being part of the result. It seems you are using the first
version of the Traversal framework, where there is not only a
StopEvaluator, but even a ReturnEvaluator that determines what to return.

Alternatively, have a look at Cypher (
http://docs.neo4j.org/chunked/snapshot/tutorials-cypher-java.html from
Java) with the LIMIT keyword, see
http://docs.neo4j.org/chunked/snapshot/query-limit.html)

HTH

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/


On Wed, Feb 8, 2012 at 10:58 AM, Emil Dombagolla <
em...@hsenidoutsourcing.com> wrote:

> Hi all,
>
> Please help me.
>
> I user Traverse API . I want to get node list from the database and that
> should be limited to 2 nodes.(similar Sql limit query). How can i stop
> the traverse when it found 2 nodes.
>
> i try something as follows but still returns all the nodes found.
>
> return getRefereneNode().getUnderlyingNode().traverse(Order.BREADTH_FIRST,
> new LimitEvaluator(),
>  ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.TEMP_EMAIL,
> Direction.OUTGOING);
>
> private class LimitEvaluator implements StopEvaluator{
>  @Override
> public boolean isStopNode(TraversalPosition currentPos) {
> return currentPos.returnedNodesCount()>=2;
> }
> }
> Please help on this.
> Thanks
> Emil Dombagolla,
> _______________________________________________
> NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please
> register and consider posting at
> https://groups.google.com/forum/#!forum/neo4j
>
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to