# Odd filter behavior

**URL:** <https://community.stardog.com/t/odd-filter-behavior/1081>\
**Category:** Support\
**Created:** [June 7, 2018, 1:10pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081 "2018-06-07T13:10:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan.kumps](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/johan.kumps/32/201_2.png) [@johan.kumps](https://community.stardog.com/u/johan.kumps)\
**Post date:** [June 7, 2018, 1:10pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/1 "2018-06-07T13:10:38Z")

</div>

Hi,

I'm trying to filter my data using this query:

prefix sosa: [http://www.w3.org/ns/sosa/](http://www.w3.org/ns/sosa/)  
prefix qudt: [http://qudt.org/schema/qudt#](http://qudt.org/schema/qudt#)

select ?v ?o  
where {  
?o a sosa:Observation .  
?o sosa:hasFeatureOfInterest ?foi .  
?o sosa:phenomenonTime ?t .  
?o sosa:hasResult ?r .  
?r qudt:numericValue ?v .  
FILTER (?v \< 10.0)  
}

The value of the ?v parameter is 2.5. Unfortunately I don't get any results of the query but when I change my filter to FILTER(?v \> 10.0) I get the triple with the 2.5 value out of the DB.

What is wrong here?

Johan,

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [June 7, 2018, 1:15pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/2 "2018-06-07T13:15:27Z")

</div>

I would check your datatypes on the qudt:numericValue field. It looks like they’re being compared as strings.

---

<div class="post-metadata">

**Author:** ![johan.kumps](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/johan.kumps/32/201_2.png) [@johan.kumps](https://community.stardog.com/u/johan.kumps)\
**Post date:** [June 7, 2018, 1:28pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/3 "2018-06-07T13:28:44Z")

</div>

Hi Stephen,

What would that mean for the filter? Changing it to FILTER (?v \< “10”) does not help. When I add the triple the object is a string.

Johan,

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [June 7, 2018, 1:35pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/4 "2018-06-07T13:35:33Z")

</div>

You would need to set the data type to a number type if you want them compared as numbers. When talking straight string comparison, “2.5” \> “10.0” because “2” \> “1”

---

<div class="post-metadata">

**Author:** ![johan.kumps](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/johan.kumps/32/201_2.png) [@johan.kumps](https://community.stardog.com/u/johan.kumps)\
**Post date:** [June 7, 2018, 7:20pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/5 "2018-06-07T19:20:37Z")

</div>

Stephen,

Apparently the data was wrongly inserted as strings. I changed that to the correct datatypes and all is working fine.

Thanks for the tip!

Johan,

---

<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 21, 2018, 7:20pm UTC](https://community.stardog.com/t/odd-filter-behavior/1081/6 "2018-06-21T19:20:37Z")

</div>

Closed on June 21, 2018, 7:20pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
