Talk:Wikidata/Development/Queries

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

Transitive properties[edit]

One thing I have repeatedly noticed in writing my tools is the need to determine if an item is "downstream" of a chain. Example queries:

Descendant of
Follow [mother,father] up the chain
Is in taxonomic group
Follow [genus,family,order,class,phylum,taxonomic group] up the chain
Is in a country/administrative unit
Follow [is in.../country] up the chain

I know these queries are expensive, but they crop up so often that it would be a shame if they could not be queried by the system, but had to be crawled through the API. --Magnus Manske (talk) 17:16, 28 March 2013 (UTC)

I agree with Magnus. Reading around, it seems that the simple entailment in the examples above is a core feature of querying in the Semantic Web. Emw (talk) 13:59, 30 March 2013 (UTC)
Basically, you are looking for Wikidata to calculate the transitive closure of a property. This kind of reasoning is likely to be very much requested, and we have to figure out if and how we can deal with it, but it not likely to happen to soon: we first need to get the basics -- i.e. queries against the explicit statements -- working and understand their implication on the infrastructure, before we can seriously start working on supporting features like transitivity. --denny (talk) 12:14, 3 April 2013 (UTC)
Thanks for the reply Denny. I've added a ticket to track this: https://bugzilla.wikimedia.org/show_bug.cgi?id=50911. Emw (talk) 23:05, 7 July 2013 (UTC)

Cache invalidation[edit]

How do you plan to address cache invalidation for pages using a query? GWicke (talk) 22:23, 28 March 2013 (UTC)

A Wikipedia article can only use a query entity, not a query (i.e. it can only refer to a named query which is represented by a page in Wikidata). Keeping track of all pages that use a specific named query is simple, and then we can use the dispatcher mechanism to send an appropriate update job to all respective pages using a query when the query result have changed (the job could, based on the progress in Parsoid, even trigger a partial reparse, hopefully). So that part is easy, and probably the one you were asking about.
The hard part is figuring out when a query entity needs to be updated, and this is a much harder question and completely depends on the type of query descriptions that we allow. But the good news, and which make this task tractable, is that the information is completely local to Wikidata. In the worst case the queries could just be run based on a human trigger or periodically, similarly to the way category pages work on Wikipedia, and trigger a change job to the client Wikis if the result set changes, but I hope we can do something more automatic. --denny (talk) 12:14, 3 April 2013 (UTC)

Better naming?[edit]

Overall, I think this approach makes perfect sense, and it mirrors the approach taken by Semantic MediaWiki, so we know that it can work in practice. My concern is with the naming - something like "QueryConcept" doesn't really indicate what it's doing. So here are my suggestions:

  • Instead of QueryConcept, how about QuerySelector? I think it's a clearer description, and "selector" is how that sort of thing is referred to in jQuery.
  • Instead of SelectionRequest, how about QueryPrintout? Again, I think it's clearer, and "printout" is the name for it in Semantic MediaWiki.
  • QueryOption, on the other hand, seems fine to me. Yaron K. (talk) 15:23, 3 April 2013 (UTC)

Simple queries[edit]

I tried to use the new {{#property}} feature of Wikidata phase II to create new taxon-infobox in hewiki which will work simply by {{taxonbox}}. In order to do it I had to write "too much" Lua (e.g i cant use [[{{#property:genus}}]] because it may give disambig, so what I want is [[{{#property:genus|hewiki-sitelink}}]] - which is painful to do with Lua). I think that queries should have some "Graph API" as facebook API - it would be very powerful to do things like:

  • {{#query:Pprop/label}} - get the label of property "prop" from the entity linked to current page
  • {{#query:Pprop/sitelink/enwiki}}- get the sitelink on enwiki of property "prop" from the entity linked to current page
  • {{#query:QcapitalCity/links[population>1500]}} (attribute selector syntax - the same as css/jquery) - get capital cities with popultion> 1500

ערן (talk) 11:21, 6 April 2013 (UTC)