# How to do path queries with whitelisted "waypoint" nodes?

**URL:** <https://community.neo4j.com/t/how-to-do-path-queries-with-whitelisted-waypoint-nodes/41111>\
**Category:** Neo4j Graph Platform\
**Created:** [July 9, 2021, 2:11am UTC](https://community.neo4j.com/t/how-to-do-path-queries-with-whitelisted-waypoint-nodes/41111 "2021-07-09T02:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_C](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/d_c/32/19041_2.png) [@D\_C](https://community.neo4j.com/u/D_C)\
**Post date:** [July 9, 2021, 2:11am UTC](https://community.neo4j.com/t/how-to-do-path-queries-with-whitelisted-waypoint-nodes/41111/1 "2021-07-09T02:11:47Z")

</div>

I saw somewhere in the docs a way to do advanced queries with "whitelisting" nodes, but I can't find it now. Can anyone help with a link?

I want to do a path search in that all the nodes share a common property, but for some reason a basic `()-[]-()` type query is returning many other nodes in the middle. I can't seem to control the node properties So I thought I would try the more complicated way to do it!

I have a query a bit like:

```auto
    match path = 
    (n1)-[*1..4]-(n2)
    where
         n1.flow = 'BILL' 
         and n2.flow = 'BILL'
    return path 
    limit 20

```

so nodes n1 and n2 should only be with BILL flow.  
However nodes with other properties are being returned in the path...

afaik the `[...]` is just for pattern matching on relations, not on intermediate nodes.  
So the above is basically like writing

`start(bill)-anything-end(bill)` where anything is not controlled by the query above.

So whitelisting to specify node properties seems like one approach?  
Perhaps I could also grab everything and just manually walk the graph and filter out nodes that don't match.

---

<div class="post-metadata">

**Author:** ![D\_C](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/d_c/32/19041_2.png) [@D\_C](https://community.neo4j.com/u/D_C)\
**Post date:** [July 9, 2021, 8:42pm UTC](https://community.neo4j.com/t/how-to-do-path-queries-with-whitelisted-waypoint-nodes/41111/2 "2021-07-09T20:42:50Z")

</div>

found it, it's part of APOC

> **[Expand to subgraph - APOC Extended Documentation](https://neo4j.com/labs/apoc/4.1/graph-querying/expand-subgraph/#expand-subgraph-examples-whitelist-blacklist)**
>
> This section describes a procedure that expands a subgraph from a set of start nodes, and returns all nodes and relationships within the subgraph.
