How to write SPARQL query that efficiently matches string literals while ignoring case

后端 未结 2 580
情话喂你
情话喂你 2020-12-16 14:54

I am using Jena ARQ to write a SPARQL query against a large ontology being read from Jena TDB in order to find the types associated with concepts based on rdfs label:

<
2条回答
  •  长情又很酷
    2020-12-16 15:33

    From all the the possible string operators that you can use in SPARQL, regex is probably the most expensive one. Your query might run faster if you avoid regex and you use UCASE or LCASE on both sides of the test instead. Something like:

    SELECT DISTINCT ?type WHERE {
     ?x  ?term .
     ?x  ?type .
     FILTER (lcase(str(?term)) = "tylenol")
    }
    

    This might be faster but in general do not expect great performance for text search with any triple store. Triple stores are very good at graph matching and not so good at string matching.

提交回复
热议问题