How to process case-insensitive SPARQL data in MarkLogic

I'm trying to figure out how best to handle literals in MarkLogic SPARQL data, which can be anyway. I would like to be able to do case-insensitive searches, but I believe this is not possible with semantic queries. For a simplified example, I want:

SELECT * WHERE { ?s ?p "Red"} 

and

 SELECT * WHERE { ?s ?p "Red"} 

to return all values: Red, Red, Red, or Red.

My data is obtained from another source that has variable capitalization rules. At the moment, I can only add an extra triple that always contains lowercase text, so I can always find this value. Alternatively, does it make sense to create some new range query in MarkLogic with case-insensitive matching (if possible with triple data)?

+5
source share
1 answer

You can use a filter that ignores case.

 select * where { ?s ?p ?o FILTER (lcase(str(?o)) = "red") } 

Based on the answer to another question .

Edit: I asked Steve Buxton, MarkLogic PM for semantic functions, and he suggested the following:

 let $store := sem:store( (), cts:element-value-query(xs:QName("sem:object"), "red", "case-insensitive") ) return sem:sparql(' SELECT ?o WHERE { ?s ?p ?o FILTER (lcase(str(?o)) = "red") }', (), (), $store ) 

sem: store is MarkLogic 8 (now available through Early Access ), which selects a group of three. Then the SPARQL query is executed on a reduced set, limiting the number of triples that need to be filtered.

+5
source

Source: https://habr.com/ru/post/1208171/


All Articles