query-9db6bd9da860ee8d5ccd35aeea78d5d2

rq turtle/ttl

Stopping a timeout on castles in the UK which keeps timing out. But no joy, it still times out, which really frustrating as there are only about 4000 castle sites in the UK (Q145)United Kingdom in the (Q23413)castle explains a timeout workaround to get a list of museums in Northern Ireland, which works. Great I thought, I'd use that for https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization#Optimization_strategies

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?place ?placeLabel ?placeDescription ?location ?tripadvisor 
  (GROUP_CONCAT(?categoryLabel; SEPARATOR = ", ") AS ?categories) WHERE {
  {
    SELECT ?place ?categoryLabel ?placeLabel ?placeDescription ?tripadvisor ?location WHERE {
      ?place wdt:P131* wd:Q145 .
      wd:Q23413 ^wdt:P279*/^wdt:P31 ?place .
      ?place wdt:P31 ?category.
      OPTIONAL { ?place wdt:P3134 ?tripadvisor.}
      ?place wdt:P625 ?location.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
    }
  }
}
GROUP BY ?place ?placeLabel ?placeDescription ?location ?tripadvisor

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?categories") v2("?category") v5("?categoryLabel"):::projected v4("?location"):::projected v1("?place"):::projected v3("?tripadvisor"):::projected a1((" ")) c9(["bd:serviceParam"]):::iri c11(["en-GB,en"]):::literal c2(["wd:Q145"]):::iri c4(["wd:Q23413"]):::iri v1 --"wdt:P131"--> c2 a1 --"wdt:P279"--> c4 v1 --"wdt:P31"--> a1 v1 --"wdt:P31"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P3134".-> v3 end v1 --"wdt:P625"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind1[/"?categoryLabel"/] v5 --o bind1 bind1 --as--o v6