[Mulgara-general] Problem using $score with LuceneModel.

Frederic Bergeron FBergeron at rocketmail.com
Tue Nov 13 15:41:48 UTC 2012


I am having a hard time trying to use the special variable $score with a LuceneModel.  Hopefully someone can help me.

Originally, I had a SPARQL request like this: 

PREFIX dct: <http://purl.org/dc/terms/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX stuff: <http://mystuff.com/reference#>
PREFIX server: <#>

select DISTINCT ?s
where {
    ?s rdf:type <stuff:LearningObject> .
        graph server:mylucene {
            ?s dct:title "myKeyword"
        graph server:mylucene {
            ?s dct:description "myKeyword"

This works fine AFAIK.

Now, I would like to do the same request but sort the results according to Lucene's ranking.  To achieve this, the documentation mentions the $score special variable.  Unless I have overlooked it, the documentation doesn't explain how to use it.

I found an example that works here though:


According to this exchange on the mailing-list, if I understand well, I must use TQL instead of SPARQL to use $score so I started to convert my previous SPARQL query to TQL like follow:

select $s $score from <rmi://localhost/comete#main>
where $s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://mystuff.com/reference#LearningObject> in <rmi://localhost/comete#main>
and $s <http://mulgara.org/mulgara#search> $q in <rmi://localhost/comete#mylucene> 
and $q <http://purl.org/dc/terms/description> 'myKeyword' in <rmi://localhost/comete#mylucene>
and $q <http://mulgara.org/mulgara#score> $score in <rmi://localhost/comete#mylucene>

This works fine.

Now, I would like to add another test on another predicate (like in my original SPARQL query in the first UNION clause).

I tried a few things and got the following error:

Error executing command. Reason: org.mulgara.query.QueryException: Query failed: Only one predicate supported per search: pred1=http://purl.org/dc/terms/title, pred2=http://purl.org/dc/terms/description

Is it possible to use $score with a test involving more than one predicate on the LuceneModel?  How can I do that using TQL?

Frederic Bergeron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-general/attachments/20121113/40aef2e0/attachment.html>

More information about the Mulgara-general mailing list