%META:TOPICPARENT{name="VirtTipsAndTricksGuide"}%
---++How Can I Perform Case Insensitive Search across multiple Literal values with Virtuoso?
If you use contains, it will make an approximate filtering of results, its is therefore best to use FILTER with bif:lower.
For example with the following RDF triples loaded in Virtuoso:
"An?lisis" .
"Aut?nomas" .
"Autonom?a de gobierno" .
"Autonom?a" .
"Auton?mica" .
"Com?n" .
"Comunidades" .
"Cr?tico" .
The following query is case sensitive, thus no data is returned as is expected:
SQL> SPARQL
PREFIX sioc_t:
SELECT DISTINCT ?s
FROM
WHERE
{
?s sioc_t:Tag ?Tag. FILTER ( ?Tag in ('analisi', 'autonomas',
'autonomia de gobierno',
'autonomia', 'autonomica',
'comun', 'comunidades', 'critico' ) )
}
-- Query result:
s
ANY
No. of rows in result: 0
Changing the query to use the Virtuoso bif:lower function a case insensitive filter is performed returning one distinct row:
SQL>SPARQL
PREFIX sioc_t:
SELECT DISTINCT ?s
FROM
WHERE
{
?s sioc_t:Tag ?Tag. FILTER ( bif:lower(str(?Tag)) in ('analisi', 'autonomas',
'autonomia de gobierno',
'autonomia', 'autonomica',
'comun', 'comunidades', 'critico' ) )
}
-- Query result:
s
ANY
http://gnoss/000066A5-E5C4-4317-AC9F-4A226E65AE4D
No. of rows in result: 1
---+++Related
* [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]]
* [[http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparqlrulefulltext][Using Full Text Search in SPARQL]]