# Search and SPARQL textmatch return different results

**URL:** <https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168>\
**Category:** Support\
**Created:** [August 1, 2018, 11:06am UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168 "2018-08-01T11:06:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuthatch](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nuthatch](https://community.stardog.com/u/nuthatch)\
**Post date:** [August 1, 2018, 11:06am UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/1 "2018-08-01T11:06:00Z")

</div>

Hello,

When I run the following two queries, I would have expected to retrieve the exact same results:

1. `stardog query search -q "Person" -l 100 mydb`

2. `stardog query mydb "SELECT DISTINCT ?s ?score WHERE { ?s ?p ?l. (?l ?score) <tag:stardog:api:property:textMatch> ('Person' 100). } ORDER BY DESC(?score)`

However, even though many results have the exact some score, some don't. I have a literal in the db which has the value "[http://www.w3.org/ns/person#Person](http://www.w3.org/ns/person#Person)".

In case 1) the returned score is 11.239, whereas in 2) the returned score is 1.123 for the corresponding subject.

From my dataset, it is obvious that 1), i.e. the higher score, must be correct, and that 2) is too low.

Is there something wrong with my SPARQL query, or am I missing something?

I observed the same problem with stardog v5.3.2 and v5.2.2.

Thanks for your help!

---

<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:** [August 1, 2018, 11:25am UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/2 "2018-08-01T11:25:40Z")

</div>

Are you able to provide a minimal data set that can reproduce this issue? If I load just one triple with that literal as the object I see the same results for those 2 queries…

---

<div class="post-metadata">

**Author:** ![nuthatch](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nuthatch](https://community.stardog.com/u/nuthatch)\
**Post date:** [August 1, 2018, 12:27pm UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/3 "2018-08-01T12:27:06Z")

</div>

I tried to create a minimal data set, and while doing so I observed that the SPARQL textmatch appears to be buggy only when the score is greater than 10. Would it be possible for you to create a dataset for yourself, in which a search query has a score \> 10 and to observe the behavior for the SPARQL variant? Otherwise I will work on an example that I can share with you.

Edit:  
I noticed a pattern - too bad I didn’t realise it before. The first digit simply gets lost when the number is \>10.

In the example of my first post, 11.23 became 1.23. In other examples I created 10.6 became 1.06 etc.

My assumption is that this is a bug?

---

<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:** [August 1, 2018, 2:45pm UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/4 "2018-08-01T14:45:13Z")

</div>

Can you confirm that there isn’t an `E1` at the end of the lower score? Often the default output for numbers in a SPARQL query is in scientific notation. It would explain why the difference you note is a power of ten.

---

<div class="post-metadata">

**Author:** ![nuthatch](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nuthatch](https://community.stardog.com/u/nuthatch)\
**Post date:** [August 1, 2018, 2:50pm UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/5 "2018-08-01T14:50:53Z")

</div>

It’s there! Thanks, I was not aware of this.

---

<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:** [August 15, 2018, 2:50pm UTC](https://community.stardog.com/t/search-and-sparql-textmatch-return-different-results/1168/6 "2018-08-15T14:50:54Z")

</div>

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