Hi all,
I am building a Question Answering System for Wikidata (I will put the
demo live in May) and would like to be able to ask quesitons like "Give
me the cities in Alaska". To query Wikidata I am using the Wikidata
SPARQL endpoint.
The SPARQL query for this question looks the following way [0]:
SELECT DISTINCT ?x ?xLabel
{
# All things in Alaska
?x (wdt:P131+ | wdt:P276) wd:Q797 .
# All cities
?x ((wdt:P106 | wdt:P39 | wdt:P31) / wdt:P279*) wd:Q515 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
As it needs to join over two very large sets (the set of all cities and
the set of all things in Alaska) the query times out. Do you have an
idea how I could write the query without getting a timeout?
Thank you ;)
[0]
https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fx%20%3FxLabel%0A%7B%0A%3…
--
Best,
Anatoly Zelenin