Hello Erik,
Congrats on this more efficient way of filtering.
Instead of using "?item ?property ?value" you could maybe use "?item wikibase:sitelinks ?c" to make sure to select here only items and not properties, lexemes... "?item a wikibase:Item" is not supported by the query service.
It could be also interesting to convert the "MINUS { ?item wdt:P31 wd:QXXX }" to "MINUS { ?item wdt:P31/wdt:P279* wd:QXXX }" in order to filter also all items that are instances of subclasses of the filtered class.
Cheers,
Thomas
Le 26 juil. 2017 à 07:26, Erik Moeller eloquence@gmail.com a écrit :
A small update on this: based on some off-list feedback, I replaced the way I exclude disambiguation pages and the like from the autocomplete list. The autocomplete widget now performs two queries: a MediaWiki API (wbsearchentities) query, and a follow-up WDQS SPARQL query to exclude disambiguation pages, Wikinews articles, and other content that folks are most likely not interested in reviewing.
I didn't find a good example for this in the examples directory, so I figured folks might find the query I'm using useful. Before I add it to the examples, please let me know if you see obvious ways in which it can be improved.
Here's an example query:
# For a list of items, exclude the ones that have "instance of" set to # one from a given set of excluded classes SELECT DISTINCT ?item WHERE { ?item ?property ?value
# Excluded classes: disambiguation pages, Wikinews articles, etc. MINUS { ?item wdt:P31 wd:Q4167410 } MINUS { ?item wdt:P31 wd:Q17633526 } MINUS { ?item wdt:P31 wd:Q11266439 } MINUS { ?item wdt:P31 wd:Q4167836 } MINUS { ?item wdt:P31 wd:Q14204246 }
# Set of items to check against the above exclusion list # wd:Q355362 is a disambiguation page and will therefore not be in # the result set VALUES ?item { wd:Q23548 wd:Q355362 wd:Q1824521 wd:Q309751 wd:Q6952373 } }
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata