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

Paul Gearon gearon at ieee.org
Tue Nov 13 16:23:47 UTC 2012


Hi,

On Tue, Nov 13, 2012 at 10:41 AM, Frederic Bergeron <
FBergeron at rocketmail.com> wrote:

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

It's been a while since I've used a Lucene model, but I thought that it was
a special predicate and not a special variable? If I'm wrong, then let me
know, and I'll look at the source code to figure it out (I haven't looked
in the Lucene code for a long time).


> 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"
>         }
>     }
>     UNION
>     {
>         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:
>
> http://lists.mulgara.org/pipermail/mulgara-general/2010-August/001139.html
>
> 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:
>

Ah, I'd forgotten about this (and no one reminded me). Yes, I need to fix
this so that it's more accessible from SPARQL (I think you can still get to
the Lucene graph by using a FROM clause). However, since I need to get
moving and implement SPARQL 1.1 I should get it done in there.


> 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?
>

I thought that it was. Did you try to re-use the $score variable? Can I see
the query please?

Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-general/attachments/20121113/1eeadded/attachment.html>


More information about the Mulgara-general mailing list