# Variable Path Queries

**URL:** https://community.stardog.com/t/variable-path-queries/4579
**Category:** Support
**Created:** [September 4, 2023, 11:13am UTC](https://community.stardog.com/t/variable-path-queries/4579 "2023-09-04T11:13:07Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Avijeet\_Gupta1](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/avijeet_gupta1/32/1922_2.png) [@Avijeet\_Gupta1](https://community.stardog.com/u/Avijeet_Gupta1)
#### Post date: [September 4, 2023, 11:13am UTC](https://community.stardog.com/t/variable-path-queries/4579/1 "2023-09-04T11:13:07Z")

</div>

Like in some other graph DBs, is there a provision in Stardog where we could get the path from start node to end node which are minimum x hops and maximum y hops away.  
For example :  
I want to check what nodes are away from one node A with minimum 2 hops and maximum 4 hops away.  
A -\> B -\> C [2 hops away]  
A -\> B -\> C -\> D [3 hops away]  
A -\> B -\> C -\> D -\> E [4 hops away]  
I want to get all the possible paths from 2 to 4 hops away from a particular node .

---

<div class="post-metadata">

### Author: ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)
#### Post date: [September 4, 2023, 11:51am UTC](https://community.stardog.com/t/variable-path-queries/4579/2 "2023-09-04T11:51:53Z")

</div>

Hi Avijeet,

Yes, have a look at the path queries section: [Path Queries | Stardog Documentation Latest](https://docs.stardog.com/query-stardog/path-queries)

There's no syntax for limiting the path length from below but you can use `MAX LENGTH` to limit it from above. If you absolutely need to filter out too short paths on the server side, you can use the [Stored Query Service](https://docs.stardog.com/query-stardog/stored-query-service#path-subqueries) to execute your path query and then put a standard SPARQL FILTER on top of that (it'd use the `stardog:length` function, see the example at the end of that section).

Cheers,  
Pavel

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [October 17, 2023, 7:21am UTC](https://community.stardog.com/t/variable-path-queries/4579/3 "2023-10-17T07:21:24Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [December 3, 2023, 4:39pm UTC](https://community.stardog.com/t/variable-path-queries/4579/4 "2023-12-03T16:39:51Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [January 24, 2024, 2:56am UTC](https://community.stardog.com/t/variable-path-queries/4579/5 "2024-01-24T02:56:56Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [March 20, 2024, 7:56am UTC](https://community.stardog.com/t/variable-path-queries/4579/6 "2024-03-20T07:56:29Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [May 27, 2024, 6:41am UTC](https://community.stardog.com/t/variable-path-queries/4579/7 "2024-05-27T06:41:14Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [November 25, 2024, 4:15am UTC](https://community.stardog.com/t/variable-path-queries/4579/8 "2024-11-25T04:15:13Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [June 20, 2025, 5:31am UTC](https://community.stardog.com/t/variable-path-queries/4579/9 "2025-06-20T05:31:31Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)
#### Post date: [February 7, 2026, 8:50am UTC](https://community.stardog.com/t/variable-path-queries/4579/10 "2026-02-07T08:50:51Z")

</div>


