Thanks, all!
I ran each query separately and reassembled the results in a spreadsheet,
so I think I got what I was after. Brand new to SPARQL, so I'll try and
figure out your correct query above.
Thanks again,
d

On Fri, Nov 6, 2015 at 5:40 PM, James Heald <[email protected]> wrote:

> Hi David,
>
> I think the issue with your query was with the line
>
> OPTIONAL {?nat rdfs:label ?nat_label filter (lang(?nat_label) = "en") .}
>
>
> The problem was that if the photographer didn't have a P27, so ?nat wasn't
> bound in the previous OPTIONAL line, then when it gets to the line above,
> with ?nat unbound, it will then be a directive to start binding labels for
> the *entire database* ... which is why it is just as well that Stas turns
> over an egg timer for each query.  :-)
>
> The way around this is to nest the two OPTIONAL clauses, one inside the
> other:
>
>    OPTIONAL {?photographer wdt:P27 ?nat .
>           OPTIONAL {?nat rdfs:label ?nat_label filter (lang(?nat_label) =
> "en") .}
>    }
>
> This should now run fine.  (Provided you remember to remove the old
> OPTIONAL line).
>
> All best,
>
>    James.
>
>
>
>
>
> On 06/11/2015 19:38, David Lowe wrote:
>
>> Might this be affecting our searches? The following query times out very
>> quickly on Chrome, and runs forever in Firefox before crashing the whole
>> browser (or is there a problem with my query?)
>>
>> PREFIX wd: <http://www.wikidata.org/entity/>
>> PREFIX wdt: <http://www.wikidata.org/prop/direct/>
>> PREFIX wikibase: <http://wikiba.se/ontology#>
>> PREFIX p: <http://www.wikidata.org/prop/>
>> PREFIX v: <http://www.wikidata.org/prop/statement/>
>> PREFIX q: <http://www.wikidata.org/prop/qualifier/>
>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>
>> SELECT ?photographer ?photographer_label ?nat ?nat_label ?dob ?dod WHERE {
>>     ?photographer wdt:P106 wd:Q33231 .    # find items that have
>> "occupation
>> (P106): photographer (Q33231) "
>>     OPTIONAL {?photographer wdt:P27 ?nat .}      # with a P19 (place of
>> birth) claim
>>     OPTIONAL {?photographer wdt:P569 ?dob .}      # ... where the pob has
>> a
>> Country
>>     OPTIONAL {?photographer wdt:P570 ?dod ;} #where the pob has a state
>>
>>     OPTIONAL {?photographer rdfs:label ?photographer_label filter
>> (lang(?photographer_label) = "en") .}
>>     OPTIONAL {?nat rdfs:label ?nat_label filter (lang(?nat_label) = "en")
>> .}
>>     #OPTIONAL {?cob rdfs:label ?cob_label filter (lang(?cob_label) =
>> "en") .}
>>     #OPTIONAL {?state rdfs:label ?state_label filter (lang(?state_label) =
>> "en") .}
>>          }
>>
>>
>
> _______________________________________________
> Wikidata mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
_______________________________________________
Wikidata mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata

Reply via email to