|
From: <gia...@op...> - 2010-01-25 03:32:25
|
Hi,
I would like to query DBPedia to build an auto-completion feature and I am
not able to figure out the best way to write the associated SPARQL.
Assuming that I would like to auto-complete 'cambri', this query should work:
SELECT ?s
WHERE {
?s rdfs:label ?label
FILTER regex( str(?label), "^cambri", "i" )
}
ORDER BY ASC(?label)
LIMIT 5
The problem is that it is too slow and timeout. People have been suggesting to use the
OpenLink Virtuoso built-in-function "contains" as it performs better than regex filters.
So, this query is better:
SELECT DISTINCT ?s
WHERE {
?s rdfs:label ?label
FILTER (bif:contains(?label, 'cambrid'))
}
ORDER BY ASC(?label)
LIMIT 5
Unfortunatelly, it is sematically incorrect as I would like to find the resources starting with 'cambrid' and not
simply containing 'cambrid'.
So, I though that combining the filter could do the trick - here, assuming that
combined filters are evaluated from left to right:
SELECT DISTINCT ?s
WHERE {
?s rdfs:label ?label
FILTER (bif:contains(?label, 'cambrid') && regex( str(?label), "^cambrid", "i"))
}
ORDER BY ASC(?label)
LIMIT 5
This query returns an empty set.
Any idea about achieving such an auto-completion.
Thanks,
Gianny
|