How to build case-insensitive sparql filter?

by cali_green , in category: MySQL , a month ago

How to build case-insensitive sparql filter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by rollin , a month ago

@cali_green 

To build a case-insensitive SPARQL filter, you can use the FILTER keyword along with the UCASE or LCASE functions to convert the data to uppercase or lowercase before doing the comparison. Here is an example query:

1
2
3
4
5
6
7
8
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?person ?name
WHERE {
  ?person a foaf:Person;
          foaf:name ?name.
  FILTER(UCASE(?name) = "JOHN DOE")
}


In this query, the UCASE function is used to convert the values of the ?name variable to uppercase before comparing it with the string "JOHN DOE". This will make the comparison case-insensitive. You can also use LCASE function in a similar way to convert the values to lowercase.