[[rest-api-traversal-using-a-return-filter]]
=== Traversal using a return filter ===

In this example, the +none+ prune evaluator is used and a return filter
is supplied in order to return all names containing "t". 
The result is to be returned as nodes and the max depth is
set to 3.


.Final Graph
["dot", "Final-Graph-Traversal-using-a-return-filter.svg", "neoviz"]
----
  N14 [
    label = "{Node\[14\]|name = \'Sara\'\l}"
  ]
  N15 [
    label = "{Node\[15\]|name = \'Johan\'\l}"
  ]
  N15 -> N16 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
  N16 [
    label = "{Node\[16\]|name = \'Emil\'\l}"
  ]
  N16 -> N19 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
  N16 -> N18 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
  N17 [
    label = "{Node\[17\]|name = \'Root\'\l}"
  ]
  N17 -> N20 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
  N17 -> N15 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knows\n"
  ]
  N18 [
    label = "{Node\[18\]|name = \'Tobias\'\l}"
  ]
  N18 -> N14 [
    color = "#4e9a06"
    fontcolor = "#4e9a06"
    label = "loves\n"
  ]
  N19 [
    label = "{Node\[19\]|name = \'Peter\'\l}"
  ]
  N20 [
    label = "{Node\[20\]|name = \'Mattias\'\l}"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/node/17/traverse/node+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{
  "order" : "breadth_first",
  "return_filter" : {
    "body" : "position.endNode().getProperty('name').toLowerCase().contains('t')",
    "language" : "javascript"
  },
  "prune_evaluator" : {
    "body" : "position.length() > 10",
    "language" : "javascript"
  },
  "uniqueness" : "node_global",
  "relationships" : [ {
    "direction" : "all",
    "type" : "knows"
  }, {
    "direction" : "all",
    "type" : "loves"
  } ],
  "max_depth" : 3
}
----


_Example response_

* *+200:+* +OK+
* *+Content-Type:+* +application/json+
[source,javascript]
----
[ {
  "outgoing_relationships" : "http://localhost:7474/db/data/node/17/relationships/out",
  "data" : {
    "name" : "Root"
  },
  "traverse" : "http://localhost:7474/db/data/node/17/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/17/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/17/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/17",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/17/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/17/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/17/relationships/in",
  "extensions" : {
  },
  "create_relationship" : "http://localhost:7474/db/data/node/17/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/17/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/17/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/17/relationships/in/{-list|&|types}"
}, {
  "outgoing_relationships" : "http://localhost:7474/db/data/node/20/relationships/out",
  "data" : {
    "name" : "Mattias"
  },
  "traverse" : "http://localhost:7474/db/data/node/20/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/20/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/20/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/20",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/20/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/20/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/20/relationships/in",
  "extensions" : {
  },
  "create_relationship" : "http://localhost:7474/db/data/node/20/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/20/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/20/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/20/relationships/in/{-list|&|types}"
}, {
  "outgoing_relationships" : "http://localhost:7474/db/data/node/19/relationships/out",
  "data" : {
    "name" : "Peter"
  },
  "traverse" : "http://localhost:7474/db/data/node/19/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/19/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/19/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/19",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/19/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/19/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/19/relationships/in",
  "extensions" : {
  },
  "create_relationship" : "http://localhost:7474/db/data/node/19/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/19/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/19/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/19/relationships/in/{-list|&|types}"
}, {
  "outgoing_relationships" : "http://localhost:7474/db/data/node/18/relationships/out",
  "data" : {
    "name" : "Tobias"
  },
  "traverse" : "http://localhost:7474/db/data/node/18/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/18/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/18",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/18/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/18/relationships/in",
  "extensions" : {
  },
  "create_relationship" : "http://localhost:7474/db/data/node/18/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/18/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/18/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/18/relationships/in/{-list|&|types}"
} ]
----


