Optimize browse page facet query

This commit is contained in:
Edward Betts 2019-11-27 12:42:07 +00:00
parent b894188f1a
commit 19e82a34cd
2 changed files with 6 additions and 4 deletions

2
app.py
View file

@ -572,6 +572,8 @@ def get_facets(params):
label = row['objectLabel']['value']
count = int(row['count']['value'])
if pid not in find_more_props:
continue
facets[pid].append({'qid': qid, 'label': label, 'count': count})
return {

View file

@ -1,11 +1,11 @@
select ?property ?object ?objectLabel (count(*) as ?count) {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
VALUES ?isa { {% for isa in isa_list %} wd:{{ isa }} {% endfor %} }
service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
values ?isa {{% for isa in isa_list %} wd:{{ isa }} {% endfor %}}
?item wdt:P31 ?isa .
?item wdt:P18 ?image .
{% for pid, qid in params %}
?item wdt:{{pid}} wd:{{qid}} .
?item wdt:{{pid}} wd:{{qid}} .
{% endfor %}
values ?property { {% for pid in properties %} wdt:{{pid}}{% endfor %} }
filter (strstarts(str(?property), "http://www.wikidata.org/prop/direct/P") )
?item ?property ?object .
} group by ?property ?propertyLabel ?object ?objectLabel