Hi Andy, I tried "Head*" but it does not work like "starts-with".
"Head*" matches "DICOM Header Tag", which just "Head" does not. So that behaves as expected. But it still does not solve my "starts-with" problem since "DICOM Header Tag" was returned as part of the results in the first place. I only want matches like "Head Carcinoma", "Head Injury" etc. I checked out the two links you sent before posting this question. The tutorial mentions starts-with using the asterisk, but it matches any word in the text that starts-with the search string which is not what I am looking for. How do I tell the text query that it should only look for matches at the start of the string? (like "^" in regex or strstarts). -Wolfgang -----Original Message----- From: Andy Seaborne <a...@apache.org> To: users <users@jena.apache.org> Sent: Thu, Nov 14, 2013 3:44 pm Subject: Re: Jena-text starts-wth On 14/11/13 14:04, Joshua TAYLOR wrote: > On Thu, Nov 14, 2013 at 7:42 AM, <huey...@aol.com> 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