Page MenuHomePhabricator

Custom RDF prefixes
Closed, ResolvedPublic

Description

Current Situation:

  • Wikibase Suite instances uses the same prefixes as wikidata in sparql
  • This collides when federating with wikidata
prefix wd: <http://www.wikidata.org/entity/> 
prefix wdt: <http://www.wikidata.org/prop/direct/> 

SELECT ?item ?itemLabel
WHERE
{
  SERVICE <https://query.wikidata.org/sparql> {
    ?item wdt:P31 wd:Q146.
    ?item rdfs:label ?itemLabel.
    FILTER(LANG(?itemLabel) = "en").
  }
}

Goal:

  • define custom prefixes for the instance (in .env?) to not collide with wikidata and allow easy federation with wikidata and local prefixes

Acceptance Criteria:

  • users can define their custom prefixes
  • federation with wikidata can be easily done in sparql using wikidata and local prefixes

[optional] Notes:

[optional] Open Questions:

Event Timeline

T335448 suggests that every wikibase should have its own prefixes. This matches wikibase.cloud docs. In the context of federation, this also makes lots of sense to me.

Apparently, this is not directly supported by WDQS though. After my first round of skimming through the code it looks like WDQS only uses one URI system which creates wikidata style prefixes from the conceptUri parameter (fallback to wikibase hostname if conceptUri is not provided).

Also, apparently, the code makes assumptions about only being used for wikidata, not for other wikibase instances:

// The strings say wikibase for historical reasons, but this means wikidata.

So at the moment WDQS will create default wikidata style prefixes based on the conceptUri.

If we provide the local wikibase instance conceptUri as parameter (what wikibase suite is currently introducing: PR, PR) we will end up with prefixes like

PREFIX wdt: https://wikibase.example/prop/direct/
PREFIX wd: https://wikibase.example/entity/

These will collide with wikidata prefixes, so this should actually be avoided.

But if we would like to stick to wikidata prefixes for wikidata and provide our own local instance prefixes in addition (to easily write federated queries), we would need to provide WDQS with a conceptUri set to http://wikidata.org, which feels wrong for a local instance. But maybe it is the way for now?

We could maybe add the local prefixes on top via prefixes.conf