I've just changed the code to not prepend the default field to the query string.

It was being done because it is needed by Solr but, on reading the Solr code (again), I see now that Jena should set the default field of the SolrQuery object.

This frees up the string to be unmangled if no predicate is given.

        Andy

On 13/01/14 16:34, Pierre-Andre Michel wrote:

On Jan 13, 2014, at 2:10 PM, Andy Seaborne <[email protected]> wrote:

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).

OK...


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.

OK,  I will try what you suggest and tell you if it works or not.




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)

Would be a real improvement


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.


Thanks a lot,
will feedback you during the week.


        Andy


Thanky in advance for your answer,
Pierre-André






Reply via email to