On 14/11/13 14:04, Joshua TAYLOR wrote:
On Thu, Nov 14, 2013 at 7:42 AM, <[email protected]> wrote:
I am using the following query to get all concepts that start with the word
"Head".
PREFIX text: <http://jena.apache.org/text#>
PREFIX nci: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE {
?s text:query (nci:Preferred_Name 'Head') .
?s nci:Preferred_Name ?prefName .
FILTER ( regex(?prefName, "^Head", "" ))
}
Is there a way of doing that in the text query itself without having to add a
FILTER?
Maybe the Jena Lucene combination can do something without a FILTER,
but I don't know much about that, and can't help you out there. I
would point out, though, that you can make this FILTER less expensive
by using SPARQL 1.1's STRSTARTS:
filter( strstarts( str(?prefName), "Head" ))
You can use the full Lucene query syntax:
?s text:query (nci:Preferred_Name 'Head*') .
http://www.lucenetutorial.com/lucene-query-syntax.html
http://lucene.apache.org/core/4_3_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html
on the default field.
Andy