# FILTER EXISTS inside OPTIONAL

**URL:** <https://community.stardog.com/t/filter-exists-inside-optional/1209>\
**Category:** Bug\
**Created:** [August 10, 2018, 7:18am UTC](https://community.stardog.com/t/filter-exists-inside-optional/1209 "2018-08-10T07:18:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palladium](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Palladium](https://community.stardog.com/u/Palladium)\
**Post date:** [August 10, 2018, 7:18am UTC](https://community.stardog.com/t/filter-exists-inside-optional/1209/1 "2018-08-10T07:18:11Z")

</div>

Hello,  
in Stardog 5.3.3 Community there seems to be an issue with FILTER EXISTS inside an OPTIONAL block (see Query #1).

Create an empty default database with reasoning being disabled both in the database and the query settings.  
The stardog.log file does not show any entries about it.

Result R#1 -\> Q#1:  
?pet  
(empty)

Result R#1 -\> Q#2:  
?pet  
ex:Rex

Result R#1 -\> Q#3:  
?pet  
ex:Rex

Request #1:

> ```
> PREFIX ex: <http://example.org#>
> INSERT DATA {
> ex:Rex a ex:Dog
> }
> 
> ```

Query #1:

> ```
> PREFIX ex: <http://example.org#>
> SELECT *
> WHERE {
> OPTIONAL {
> BIND (ex:Rex AS ?pet)
> FILTER EXISTS { ?pet a ex:Dog }
> }
> }
> 
> ```

Query #2:

> ```
> PREFIX ex: <http://example.org#>
> SELECT *
> WHERE {
> OPTIONAL {
> BIND (ex:Rex AS ?pet)
> ?pet a ex:Dog
> }
> }
> 
> ```

Query #3:

> ```
> PREFIX ex: <http://example.org#>
> SELECT *
> WHERE {
> BIND (ex:Rex AS ?pet)
> FILTER EXISTS { ?pet a ex:Dog }
> }
> 
> ```

Best regards,  
Palladium

---

<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:** [August 10, 2018, 7:28am UTC](https://community.stardog.com/t/filter-exists-inside-optional/1209/2 "2018-08-10T07:28:53Z")

</div>

Thanks for the concise report, we’ll take a look.

Best,  
Pavel

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [August 10, 2018, 3:19pm UTC](https://community.stardog.com/t/filter-exists-inside-optional/1209/3 "2018-08-10T15:19:16Z")

</div>

Thanks for the bug report. I have created issue #5982 to track this.

Jess
