On 12/01/14 17:34, Pierre-Andre Michel wrote:
Hello,
I am playing with the text:query property function.
The following query searches for var ?a where must meet 2 criteria, one related
to predicate pred:cv-name, the other one to predicate pred:cv-synonym.
PREFIX pred: <http://nextprot.org/rdf/pred/>
PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX text: <http://jena.apache.org/text#>
SELECT *
where {
?a text:query(pred:cv-name 'ubl' 5) . <== first criterion
?a text:query(pred:cv-synonym 'ubiquitin' 10) . <== second criterion
?a pred:cv-name ?n .
?a pred:cv-synonym ?d .
}
When I trace the solr index calls, here is what I see:
657968 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_name:ubl&wt=javabin&version=2&rows=5} hits=172
status=0 QTime=1
657972 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_synonym:ubiquitin&wt=javabin&version=2&rows=10000}
hits=256 status=0 QTime=1
657977 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_synonym:ubiquitin&wt=javabin&version=2&rows=10000}
hits=256 status=0 QTime=1
657982 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_synonym:ubiquitin&wt=javabin&version=2&rows=10000}
hits=256 status=0 QTime=2
657986 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_synonym:ubiquitin&wt=javabin&version=2&rows=10000}
hits=256 status=0 QTime=1
657991 [qtp1936269821-15] INFO org.apache.solr.core.SolrCore ? [rdf1] webapp=/solr
path=/select params={q=cv_synonym:ubiquitin&wt=javabin&version=2&rows=10000}
hits=256 status=0 QTime=1
It seems that the search related to the second criterion is called once for
each solution found for first criterion.
Is my interpretation correct ?
Yes - that's how this query will be executed. ARQ normal mode of
execution is to start at some point (it does not move property functions
around because it has no idea which are selective or expensive).
> is there a workaround to compute mutiple text:query and do a single
binding to var ?a ?
It may work (=> I haven't tried) to make the query name some of the
fields. The predicate, or default if not mentioned, is always added to
the front of the string but no other processing happens.
So if you write:
?a text:query(pred:cv-name 'ubl AND field2:ubiquitin' 10) .
where field2 is the name of text:field name then you may be a single,
conjunctive query.
Looking at the code, I can see no reason why the form of query could not
be changed to
?a text:query( predicate1 "string1" predicate2 "string2" ... limit)
The types of the items can be used to distinguish the required
processing. It would only be conjunctions though.
So maybe better is not prepend the default field name and, without a
given predicate, you get a direct lucene query string. The default is
supposed to be the default so it shoudl not need prepending. This, of
course, needs testing
In case anyone want to try this, see TextQueryPF.objectToStruct around
line 230.
Andy
Thanky in advance for your answer,
Pierre-André