# Similarity Search Empty results

**URL:** <https://community.stardog.com/t/similarity-search-empty-results/1233>\
**Category:** Support\
**Created:** [August 21, 2018, 12:01pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233 "2018-08-21T12:01:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 21, 2018, 12:01pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/1 "2018-08-21T12:01:33Z")

</div>

Started exploring the new "Similarity Search" feature. Before using it at my own data, I thought it would be good to use it first on the movie dataset. Therefore, I tried to replicate the steps used in the blog post "[Similarity Search | Stardog](https://www.stardog.com/blog/similarity-search/)". However, I do not succeed. I load the movie dataset in a brand new repository in Stardog 5.3.3.

Ran the Insert query from the blog post.

```auto
prefix spa: <tag:stardog:api:analytics:>

INSERT {
    graph spa:model {
        :simModel a spa:SimilarityModel ;
                  spa:arguments (?genres ?directors ?writers ?producers ?metaCritic) ;
                  spa:predict ?movie .
    }
}
WHERE {
    SELECT 
    (agg:spa:set(?genre) as ?genres) 
    (agg:spa:set(?director) as ?directors)
    (agg:spa:set(?writer) as ?writers)
    (agg:spa:set(?producer) as ?producers)
    ?metaCritic
    ?movie
    {
        ?movie :genre ?genre ;
                :director ?director ;
                :author ?writer ;
                :productionCompany ?producer ;
                :metaCritic ?metaCritic .
    }
    GROUP BY ?movie ?metaCritic 
}

```

And the select query:

```auto
prefix spa: <tag:stardog:api:analytics:>

SELECT ?similarMovieLabel ?confidence
WHERE {
    graph spa:model {
      :simModel spa:arguments (?genres ?directors ?writers ?producers ?metaCritic) ;
                spa:confidence ?confidence ;
                spa:parameters [spa:limit 5] ;
                spa:predict ?similarMovie .
    }

    { ?similarMovie rdfs:label ?similarMovieLabel }
        
    {
        SELECT 
        (agg:spa:set(?genre) as ?genres) 
        (agg:spa:set(?director) as ?directors)
        (agg:spa:set(?writer) as ?writers)
        (agg:spa:set(?producer) as ?producers)
        ?metaCritic
        ?movie
        {
            ?movie :genre ?genre ;
                    :director ?director ;
                    :author ?writer ;
                    :productionCompany ?producer ;
                    :metaCritic ?metaCritic .

            VALUES ?movie { t:tt0118715 } # The Big Lebowski
        }
        GROUP BY ?movie ?metaCritic
    } 
}

ORDER BY DESC(?confidence)

```

Something which might be relevant, with running the query in Stardog I get an "unknown prefix error on agg:" Therefore I added "PREFIX agg: urn:aggregate" to both queries.

After running the select query I get 0 results. Do I have to adjust some settings in the repository, or should it be able to work right out of the blue?

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [August 21, 2018, 1:06pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/2 "2018-08-21T13:06:05Z")

</div>

Hi Nicky,

The `unknown prefix error on agg:` error seems to indicate that you are using the deprecated webconsole. The recommended way to query Stardog is [Stardog Studio](https://www.stardog.com/studio/), which is actively maintained, and doesn't suffer from this kind of errors.

With the webconsole, you need to add `prefix agg: <urn:aggregate>` to the query, and it should work (just tested it). Webconsole has some issues with prefixes, I recommend using Studio instead. If that's not possible, can you share the results on running this query on your database?

```auto
        SELECT 
        (agg:spa:set(?genre) as ?genres) 
        (agg:spa:set(?director) as ?directors)
        (agg:spa:set(?writer) as ?writers)
        (agg:spa:set(?producer) as ?producers)
        ?metaCritic
        ?movie
        {
            ?movie :genre ?genre ;
                    :director ?director ;
                    :author ?writer ;
                    :productionCompany ?producer ;
                    :metaCritic ?metaCritic .

            VALUES ?movie { t:tt0118715 } # The Big Lebowski
        }
        GROUP BY ?movie ?metaCritic

```

-pedro

---

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 21, 2018, 1:16pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/3 "2018-08-21T13:16:09Z")

</div>

Thanks pedro for your reply.  
If I run your query

> prefix agg: urn:aggregate  
> prefix spa: tag:stardog:api:analytics:  
> prefix t: [http://www.imdb.com/title/](http://www.imdb.com/title/)
> 
> SELECT  
> (agg:spa:set(?genre) as ?genres)  
> (agg:spa:set(?director) as ?directors)  
> (agg:spa:set(?writer) as ?writers)  
> (agg:spa:set(?producer) as ?producers)  
> ?metaCritic  
> ?movie  
> {  
> ?movie :genre ?genre ;  
> :director ?director ;  
> :author ?writer ;  
> :productionCompany ?producer ;  
> :metaCritic ?metaCritic .
> 
> ```
> VALUES ?movie { t:tt0118715 } # The Big Lebowski
> }
> GROUP BY ?movie ?metaCritic
> 
> ```

I got:

SPARQL Results (returned in 354 ms)

| genres | directors | writers | producers | metaCritic | movie |
| --- | --- | --- | --- | --- | --- |
| | | | | | |

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [August 21, 2018, 1:19pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/4 "2018-08-21T13:19:27Z")

</div>

Can’t replicate that behaviour locally. Maybe add a `prefix : <http://schema.org/>` to the query? It’s hard to say. As I said, webconsole has serious issues with prefixes, and it will be gone from Stardog very soon. Let me know if you encounter the same issues when running it with Studio.

-pedro

---

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 21, 2018, 1:35pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/5 "2018-08-21T13:35:33Z")

</div>

Ok, will try the same steps via the studio. What are the future plans according to the webconsole, will it eventually be removed from the online environment?

---

<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 21, 2018, 1:40pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/6 "2018-08-21T13:40:14Z")

</div>

Yes, it will. No Webconsole in Stardog 6.

Best,  
Pavel

---

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 22, 2018, 8:31am UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/7 "2018-08-22T08:31:54Z")

</div>

Started over via Stardog Studio, get the same empty results. Started over with creating a new repository loaded the movie data and ran the insert query for creating model and the select query.

Solved it by adding the `prefix : <http://schema.org/>`, which is apparently the issue!

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [August 22, 2018, 8:35am UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/8 "2018-08-22T08:35:30Z")

</div>

Can you share the output of `stardog namespace list your_database`? You shouldn’t have to declare that prefix in the query.

---

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 22, 2018, 8:43am UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/9 "2018-08-22T08:43:15Z")

</div>

+---------+---------------------------------------------+  
| Prefix | Namespace |  
+---------+---------------------------------------------+  
| | [http://api.stardog.com/](http://api.stardog.com/) |  
| owl | [http://www.w3.org/2002/07/owl#](http://www.w3.org/2002/07/owl#) |  
| rdf | [http://www.w3.org/1999/02/22-rdf-syntax-ns#](http://www.w3.org/1999/02/22-rdf-syntax-ns#) |  
| rdfs | [http://www.w3.org/2000/01/rdf-schema#](http://www.w3.org/2000/01/rdf-schema#) |  
| stardog | tag:stardog:api: |  
| xsd | [XML Schema](http://www.w3.org/2001/XMLSchema#) |  
+---------+---------------------------------------------+

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [August 22, 2018, 12:44pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/10 "2018-08-22T12:44:26Z")

</div>

Ah, I assumed that you had bulk loaded the `movies.ttl` file, which would import the namespaces in the file. By doing a `data add`, they are not added to the list of default namespaces, so they have to be manually specified in the query.

Will update the query in the blog post 👍

---

<div class="post-metadata">

**Author:** ![nicky508](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/nicky508/32/102_2.png) [@nicky508](https://community.stardog.com/u/nicky508)\
**Post date:** [August 22, 2018, 12:53pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/11 "2018-08-22T12:53:44Z")

</div>

I used to the data upload function from the web console and the upload function from stardog studio.

---

<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:** [September 5, 2018, 12:53pm UTC](https://community.stardog.com/t/similarity-search-empty-results/1233/12 "2018-09-05T12:53:47Z")

</div>

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