title: How to write SPARQL query that efficiently matches string literals while ignoring case
body: <p>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:</p>
  
  <pre><code>SELECT DISTINCT ?type WHERE {
   ?x &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; "aspirin" .
   ?x &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; ?type .
  }
  </code></pre>
  
  <p>This works pretty well and is actually quite speedy (&lt;1 second).  Unfortunately, for some terms, I need to perform this query in a case-insensitive way.  For instance, because the label <code>"Tylenol"</code> is in the ontology, but not <code>"tylenol"</code>, the following query comes up empty:</p>
  
  <pre><code>SELECT DISTINCT ?type WHERE {
   ?x &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; "tylenol" .
   ?x &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; ?type .
  }
  </code></pre>
  
  <p>I can write a case-insensitive version of this query using FILTER syntax like so:</p>
  
  <pre><code>SELECT DISTINCT ?type WHERE {
   ?x &lt;http://www.w3.org/2000/01/rdf-schema#label&gt; ?term .
   ?x &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#type&gt; ?type .
   FILTER ( regex (str(?term), "tylenol", "i") )
  }
  </code></pre>
  
  <p>But now the query takes over a minute to complete!  Is there any way to write the case-insensitive query in a more efficient manner?</p>