After testing and playing around with the similarity search, we are trying to integrate it with one of our software tools. At this moment we are able to provide the user with a way to select object attibutes to construct a similarity search model and we are able to create a insert model and a select model. However, we are not able to get the queries to stardog via jena, because Jena does not accept the queries.
For example we run the model insert query as a update query:
Non-group key variable in SELECT: ?bouwbest in expression (urn:aggregatespa:set ?bouwbest)
The query used generated is:
prefix spa: <tag:stardog:api:analytics:>
prefix : <http://schema.org/>
PREFIX agg: <urn:aggregate>
INSERT { graph spa:model { :building_model a spa:SimilarityModel; spa:arguments (?bouwbest2 ?functie2 ?status2 ?bag_oppvlk2 ?bouwjaar2 );
spa:predict ?object .}}WHERE {
SELECT
(agg:spa:set(?bouwbest) as ?bouwbest2) (agg:spa:set(?functie) as ?functie2) (agg:spa:set(?status) as ?status2) (agg:spa:set(?bag_oppvlk) as ?bag_oppvlk2) (agg:spa:set(?bouwjaar) as ?bouwjaar2) ?object { GRAPH <http://data.resc.info/kro> {?object <http://vocab.netage.nl/kro#hasWOZ> ?hasWOZ.
?hasWOZ <http://vocab.netage.nl/kro#bouwbest> ?bouwbest.
?object <http://vocab.netage.nl/kro#hasBuilding> ?hasBuilding.
?hasBuilding <http://vocab.netage.nl/kro#functie> ?functie.
?hasBuilding <http://vocab.netage.nl/kro#status> ?status.
?hasBuilding <http://vocab.netage.nl/kro#bag_oppvlk> ?bag_oppvlk.
?hasBuilding <http://vocab.netage.nl/kro#bouwjaar> ?bouwjaar.
}} GROUP BY ?object}
The query works fine via Stardog Studio, I am curious whether there is some experience with such specific stardog query constructions and jena (or other ways to get the query to Stardog)
So only registering would be enough (without having the aggregation code which is used by Stardog), since the query executed by Stardog and not by Jena?
We do offer Jena bindings, which should allow you to run your query on Stardog without having to send it through Jena, but it will work with the rest of your application, as everything implements the Jena interface.
It appears that using the Jena bindings in Stardog still sends the query through Jena, which is the problem in the first place. Have you tried Lorenz's suggestion regarding registering the aggregate function via ARQ (Stardog similarity search query through jena - #2 by lorenz_b)?
Second, you should not use the agg: prefix in your query at all. The set aggregate function is defined in the spa namespace and agg: prefix was a workaround in old versions of Stardog that is not needed anymore (we will update the examples in our documentation). So your aggregate expressions can look like (spa:set(?bouwbest) as ?bouwbest2) with the spa namespace declaration you already have.