Reputation: 53
Trying to find if there is a property that connects two arbitrary entities on Wikidata. This works fine, unless one of the entities is in a list for the other entity. In this case only the first entity in the list is seen as being connected to the other. For example: 'Python' and 'object-based language' (first in the list for property 'instance of') return a property, but 'Python' and 'programming language' do not.
SELECT ?prop
WHERE {
wd:Q28865 ?prop wd:Q9143.
}
How to make this work for all entities in such a list?
Upvotes: 1
Views: 601
Reputation: 74036
When you use the normal wdt:
namespace for properties, you will only get the statements of the highest rank for each property. Wikidata in general has three ranks:
In your case "object-based language" (Q899523) has the preferred rank. So all statements returned need to have the same preferred rank. "programming language" (Q9143) only has normal rank and hence is not included in that namespace.
If you want all statements, afaik you have to take the detour via the statement entities like this:
SELECT *
WHERE {
wd:Q28865 ?propP ?stmt .
?stmt ?propPS wd:Q9143 ;
wikibase:rank ?rank .
FILTER( STRSTARTS( STR(?propPS), 'http://www.wikidata.org/prop/statement/' ) ) .
}
This actually uses the p:
and ps:
namespaces.
See also this subsection in the Wikidata wiki on using ranks in SPARQL.
Upvotes: 4