I'm having trouble consistently retrieving DOIs for WikiData entries for scientific articles via the query service.
As a minimal working example, the following will return the DOI for the entry Q115784452:
SELECT ?doi WHERE { wd:Q115784452 wdt:P356 ?doi . }
this works as expected and returns the DOI on the page. However, if we look at another example, Q67940907, this does have a DOI on the site but
SELECT ?doi WHERE { wd:Q67940907 wdt:P356 ?doi . }
returns no DOI.
To see this for more examples, if I follow an example from the Wikidata example page to look for all taxa that isovitexin occurs in and get the DOIs for the references, I only get DOIs for two of the statements although many of the statements should have DOIs for their references:
SELECT ?item ?refDOI ?statement
WHERE {
VALUES ?item { wd:Q3155636 } # Example:
?item p:P703 ?statement.
?statement prov:wasDerivedFrom ?refNode.
?refNode pr:P248 ?refSource.
OPTIONAL { ?refSource wdt:P356 ?refDOI }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr". }
}
LIMIT 10000
I've also tried modifying this to pull the DOI directly from the reference node with OPTIONAL {{ ?refNode pr:P356 ?refDOI. }} with no luck.
Does anyone have any suggestions as to what might fix this?
As highlighted by Tom Morris, this is an issue because of the scholarly graph split.
The queries need to be modified to also search the scholarly graph. Note that if only searching on the scholarly graph, this seems to not work for those cases that work on the main graph and so we need to search both (making them optional). The following modified queries work for me:
1.
SELECT ?doi WHERE {
OPTIONAL{ SERVICE wdsubgraph:scholarly_articles{wd:Q115784452 wdt:P356 ?doi . }}
OPTIONAL{wd:Q115784452 wdt:P356 ?doi . }}
SELECT ?doi WHERE {
OPTIONAL{ SERVICE wdsubgraph:scholarly_articles{wd:Q67940907 wdt:P356 ?doi . }}
OPTIONAL{wd:Q67940907 wdt:P356 ?doi . }}
SELECT ?item ?refDOI ?statement
WHERE {
VALUES ?item { wd:Q3155636 } # Example:
?item p:P703 ?statement.
?statement prov:wasDerivedFrom ?refNode.
?refNode pr:P248 ?refSource.
# Federate to Scholarly Wikidata for DOI
OPTIONAL{
SERVICE wdsubgraph:scholarly_articles {{
?refSource wdt:P356 ?refDOI.
}}
}
OPTIONAL{
?refSource wdt:P356 ?refDOI.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr". }
}
LIMIT 10000