You can try using the virtuoso build in "bif" functions for text search.
SELECT DISTINCT ?filmName WHERE {
?film foaf:name ?filmName .
?film dbpedia-owl:starring ?actress .
?actress foaf:name ?name.
?actress foaf:name ?name2.
?name bif:contains "Nicole" .
?name2 bif:contains "Kidman" .
}
This is much faster in reality than using filters. Unfortunately, looking at your comment the virtuoso query execution estimator disagrees.
The 2 name variables are to work around a limitation of the bif functions.
More general the contains function is normally slightly faster than the regex ones.
SELECT DISTINCT ?filmName WHERE {
?film foaf:name ?filmName .
?film dbpedia-owl:starring ?actress .
?actress foaf:name ?name.
FILTER(contains(?name, "Nicole"))
FILTER(contains(?name, "Kidman"))
}
When you have a larger number of actors you can try the following. The theory here is that less variables need to be bound and that they can be passed into a single filter call faster. You will need to measure to see what is faster.
SELECT DISTINCT ?filmName WHERE {
?film foaf:name ?filmName .
?film dbpedia-owl:starring ?actress .
?actress foaf:name ?name.
FILTER((contains(?name, "Nicole") && contains(?name, "Kidman")) || (contains(?name, "Tom") && contains(?name, "Cruise")))
}
answered
08 Jan, 10:40
Jerven
3.1k●5●10
accept rate:
31%