Search code examples
regexsparqlrdfsemantic-web

SPARQL Regex does not show what is supposed to show


I am trying to run this query on http://www.linkedmdb.org/snorql and on Jena (java) in order to get all datasets with the title "NVA" for example.

select ?f where {

            ?f dc:title  ?s.
            FILTER(REGEX(?s, "NVA", "i")).

 }

However, it shows only this result http://data.linkedmdb.org/page/film/2532 and not http://data.linkedmdb.org/page/film/4958 (the one I should get).

But by running this query, I get only the second dataset (4958) and not first

select ?f where {

            ?f dc:title  "NVA"

 }

I was wondering why my filter is not working correctly ? and what should I add to get the datasets with the exact title of my keyword in my regex?

Thanks.


Solution

  • FILTER(REGEX(?s, "NVA", "i")).
    

    The "i" means case insensitive matching. The "NVA" matches any part for the string.

    ?f dc:title "NVA"
    

    is more like:

    ?f dc:title  ?s.
    FILTER REGEX(?s, "^NVA$")