query-6ea31c3c5d061ab7e38dac64483e3f9c

rq turtle/ttl

Help Troubleshooting SPARQL Query for Wiki Loves Monuments Contest DataI'm working on a project to gather data on heritage items eligible for the Wiki Loves Monuments contest. I'm able to get the scheduled monument and Grade IIs Listed Buildings but now I am having issue getting items for Grade II Listed Buildings. I'm using a SPARQL query from previous conversation to retrieve details such as the item label, image, instance type, location, inception date, administrative entity, and historic county label for each item. However, I keep encountering a 500 error code when executing my query, indicating a server-side issue. I think the complexity of my query or a specific part of it might be causing this problem. Below is the query:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?itemLabel 
                (sample(?image_) as ?image) 
                (group_concat(distinct ?instanceOfTypeLabel_;separator="; " ) as ?instanceOfTypeLabel)  
                ?location 
                ?inception 
                (group_concat(distinct ?adminEntityLabel_;separator="; " ) as ?adminEntityLabel)  
                ?historicCountyLabel 
WHERE {
    ?item p:P1435 ?statement.
    ?statement ps:P1435/(wdt:P279*) wd:Q15700834.

    ?item wdt:P18 ?image_.
    ?item wdt:P31 ?instanceOfType.
    ?item wdt:P625 ?location.
    OPTIONAL { ?item wdt:P571 ?inception . }
    OPTIONAL { ?item wdt:P131 ?adminEntity . }
    OPTIONAL { ?item wdt:P7959 ?historicCounty . }

    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". 
                ?item rdfs:label ?itemLabel . 
                ?instanceOfType rdfs:label ?instanceOfTypeLabel_ . 
                ?adminEntity rdfs:label ?adminEntityLabel_ .
                ?historicCounty rdfs:label ?historicCountyLabel .}
} 
GROUP BY ?itemLabel ?location ?inception ?historicCountyLabel
LIMIT 1000 OFFSET 0

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?adminEntity") v15("?adminEntityLabel") v11("?adminEntityLabel_"):::projected v8("?historicCounty") v12("?historicCountyLabel"):::projected v13("?image") v3("?image_"):::projected v6("?inception"):::projected v4("?instanceOfType") v14("?instanceOfTypeLabel") v10("?instanceOfTypeLabel_"):::projected v1("?item") v9("?itemLabel"):::projected v5("?location"):::projected v2("?statement") a1((" ")) c4(["wd:Q15700834"]):::iri c14(["en"]):::literal c12(["bd:serviceParam"]):::iri v1 --"p:P1435"--> v2 v2 --"p:statement/P1435"--> a1 a1 --"p:direct/P279"--> c4 v1 --"p:direct/P18"--> v3 v1 --"p:direct/P31"--> v4 v1 --"p:direct/P625"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P571".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P131".-> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P7959".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 v1 --"rdfs:label"--> v9 v4 --"rdfs:label"--> v10 v7 --"rdfs:label"--> v11 v8 --"rdfs:label"--> v12 end bind3[/"sample(?image_)"/] v3 --o bind3 bind3 --as--o v13 bind4[/"?instanceOfTypeLabel_"/] v10 --o bind4 bind4 --as--o v14 bind5[/"?adminEntityLabel_"/] v11 --o bind5 bind5 --as--o v15