Hi all, Thanks Øyvind, Lorenz, Rob for your hints, which were very helpful 😊. Most important was to reorder patterns in query and expand paths. So that text:query pattern is at the top . There is no difference when using subquery nor enclosing text:query pattern into curly brackets. You're right also about leading wildcards which are expensive, similar query without them was ~ 2x faster that original. So the final query is:
PREFIX tes: <http://mycompany/tes/> PREFIX fhir: <http://hl7.org/fhir/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX text: <http://jena.apache.org/text#> SELECT DISTINCT ?this ?json WHERE{ ?title text:query ( tes:indexedValue "*Allergy*" ) . ?this fhir:CodeSystem.title ?title . ?this fhir:Resource.jsonContent/fhir:value ?json . ?this rdf:type fhir:CodeSystem } Thanks one again. Best regards, Paweł
smime.p7s
Description: S/MIME cryptographic signature