gbv / wikidata-jskos

Access Wikidata in JSKOS format
https://coli-conc.gbv.de/services/wikidata/
MIT License
6 stars 3 forks source link

Add /mappings?fromScheme&toScheme lookup #33

Closed nichtich closed 5 years ago

nichtich commented 5 years ago

To get a list of all mappings from Wikidata to a given concept scheme. Result would probably be limited to a maximum number, e.g. 10.000. fromScheme would be optional, set to http://bartoc.org/en/node/1940 (Wikidata) by default.

Sample query: https://w.wiki/7FY

SELECT ?item ?itemLabel ?value ?mappingType WHERE {
  ?item p:P5748 ?statement .
  ?statement ps:P5748 ?value .
  OPTIONAL { ?statement pq:P4390 ?mappingType }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} LIMIT 10000

pagination (LIMIT and OFFSET) requires a sorting, e.g. ORDER BY ?value, this may be too slow for very large concordances such as GND.

stefandesu commented 5 years ago

It would be very good to have pagination available as well, we should at least try to see whether the performance is manageable. With this, mappings could be shown in the Mapping Search as well (even though not all filters will be available).

nichtich commented 5 years ago

Implemented but missing X-Total-Count header and sorting (ORDER BY). Proposed solution:

stefandesu commented 5 years ago

We can just do a count query no matter how big the count: https://query.wikidata.org/#SELECT%20%28COUNT%28%2a%29%20AS%20%3Fcount%29%0AWHERE%20%7B%0A%20%20%3Fitem%20p%3AP227%20%3Fstatement%0A%7D