Hello Ivan,
thanks a lot for looking into my query.
Now let me see if I understand correctly:
On 09/13/2010 09:42 AM, Ivan Mikhailov wrote:
> There are two problems with this query.
> First, ?v2 and ?v5 are barely connected. It looks like the query is
> written to select the excerpt of the "best" resource about a keyword and
> the score of it, but max(?v5) seems to be redundant: the score of ?v2 is
> always the same, no matter how many branches of UNION will calculate it.
I used max() to filter out duplicate results in case we have two
statements matching with different literals (in one part of the UNION).
Then the query would return both since the score is different.
> Second issue, the visible due to an error message, is that
> the ?_n_f_t_m_ex_ may get a value of arbitrary size, as far as I can
> understand, so obtaining the "distinct" from a temporary table of all
> data is a real problem. A possible workaround it to exclude
> the ?_n_f_t_m_ex_ from distinct, something like
>
> select ?r
> (bif:concat(bif:search_excerpt(bif:vector('trueg.'), ?v2))) as
> ?_n_f_t_m_ex_
> where {
> { select distinct ?r
> where { {
> { ?r ?v1 ?v2 .
> ?v2 bif:contains "'trueg.'" }
> UNION { ?r ?v1 ?v3 . ?v3 ?v4 ?v2 .
> ?v4
> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf>
> <http://www.w3.org/2000/01/rdf-schema#label> .
> ?v2 bif:contains "'trueg.'" } } .
> ?r a ?v6 .
> ?v6
> <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#userVisible>
> 'true'^^<sopranofakes:/booleanHackUntilVirtuosoProblemIsResolved> . } LIMIT
> 10 }
> { { ?r ?v1 ?v2 .
> ?v2 bif:contains "'trueg.'" OPTION (score ?_n_f_t_m_s_) . }
> UNION { ?r ?v1 ?v3 . ?v3 ?v4 ?v2 .
> ?v4
> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf>
> <http://www.w3.org/2000/01/rdf-schema#label> .
> ?v2 bif:contains "'trueg.'" OPTION (score ?_n_f_t_m_s_) . } }
> }
>
> for one or many excerpts per ?r or
So you use the second block to make sure ?v2 is not selected distinct?
(As a side-remark: this query is generated from a query API where
?_n_f_t_m_s_ can be a sum of several weighted scores.)
> select ?r
> (bif:concat(bif:search_excerpt(bif:vector('trueg.'),
> (select ?v2 where
> { { ?r ?v1 ?v2 .
> ?v2 bif:contains "'trueg.'" OPTION (score ?_n_f_t_m_s_) . }
> UNION { ?r ?v1 ?v3 . ?v3 ?v4 ?v2 .
> ?v4
> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf>
> <http://www.w3.org/2000/01/rdf-schema#label> .
> ?v2 bif:contains "'trueg.'" OPTION (score ?_n_f_t_m_s_) . } }
> )
> ))) as
> ?_n_f_t_m_ex_
> where {
> { select distinct ?r
> where { {
> { ?r ?v1 ?v2 .
> ?v2 bif:contains "'trueg.'" }
> UNION { ?r ?v1 ?v3 . ?v3 ?v4 ?v2 .
> ?v4
> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf>
> <http://www.w3.org/2000/01/rdf-schema#label> .
> ?v2 bif:contains "'trueg.'" } } .
> ?r a ?v6 .
> ?v6
> <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#userVisible>
> 'true'^^<sopranofakes:/booleanHackUntilVirtuosoProblemIsResolved> . } LIMIT
> 10 }
> }
>
> for some single excerpt per ?r
Here the select in the bif:search_excerpt block could return several
values for ?v2, right? What would bif:search_excerpt do with them?
Concat them?
This looks very interesting but I fear it will be very very hard to get
that into my query generator which is already very complicated as it is. :P
Cheers,
Sebastian