Page MenuHomePhabricator

[Story] Maintain Query Examples
Open, NormalPublic


We would like to have a nice collection of useful query examples for the Wikidata query service on
So we can show the beauty of Wikidata and allow people to retrieve information to satisfy their needs.

Current list:

We would like to have:

  • Queries to be always 'tagged' with Q-templates ( for example {{Q|Q30|United States of America}})
  • Queries should satisfy various use cases and user groups
  • Queries should be expressive and reusable
    • Showing useful information (label, description, URL (official homepage, identifier, etc.) , image, location )
    • Use various displaying formats ( table, Image Grid, Map, Bubble Chart, Tree Map ) (Use magic comments like #defaultView:Map)
    • Work nice with 'Query explanation'
    • Include a query template if usefully
  • Queries should always use a LIMIT
  • Queries should use OPTIONAL
  • Queries should never time out
  • Multiple languages

Event Timeline

Restricted Application added a project: Discovery. · View Herald TranscriptApr 14 2016, 2:08 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

We have Query: namespace in wikidata, but I don't think it's being used. Maybe we should start using it?

Also may help having better editor/display for SPARQL like there is for Javascript. I imagine it would require creating a content handler but may be worth it.

The query namespace is going to be used later. We shouldn't use it for this at this point.

Then maybe some other namespace, like SPARQL: ?

What query namespace is reserved for?

It is for the stored queries we will use to generate lists on Wikipedia for example.

This ticket is about having:

  • Showcase queries to show the power and beauty of Wikidata.
  • Queries to explain and express the WDQS UI functionality.

I really like the idea of having sophisticated Wikibase SPARQL support, but I think we should use URL shortener [T44085] as an intermediate step for storing queries.

Smalyshev added a comment.EditedApr 15 2016, 5:53 PM

It is for the stored queries we will use to generate lists on Wikipedia for example.

If it's for SPARQL queries, then I don't see why can't we use them for examples too.

I don't think we need a shortener to store queries on Wikidata - after all, shortener is just another indexed storage, so what's the difference if we store it on shortener DB or on wikidata DB?

I think we should have a namespace where we store queries on wikidata (Query: or not, whatever we choose), with accompanying talk page for discussion, with content handler for pretty display (like Javascript) and maybe some metadata, like Template: namespace has.

Jonas updated the task description. (Show Details)Apr 15 2016, 7:02 PM
Jonas updated the task description. (Show Details)Apr 20 2016, 3:59 PM
Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptApr 20 2016, 3:59 PM
Jonas updated the task description. (Show Details)Apr 22 2016, 4:03 PM

Maybe we can sit around to at least start cleaning somewhere tomorrow? Should also be in scope of the documentation sprint.

I got the feedback that people are afraid of touching the existing queries, because it may upset authors.
Maybe we could somehow indicate that the page needs cleanup and restructuring, to motivate changes and reduce the fear of upsetting somebody.

Jonas updated the task description. (Show Details)May 20 2017, 8:39 PM

Good point. So we need to find a way to find out what queries are useful. Are we tracking the amount of clicks on them?

AFAIK there is no easy way to find out what queries are clicked....
Is there a template we could use to indicate 'needs cleanup' ?

We could add it as an option to SPARQL/SPARQL2 template that queries use (or at least supposed to).

This task doesn't read as a story, but more like recurring house keeping. Maybe rewrite it into something more actionable or create new more focused stories?

abian added a subscriber: abian.Jul 26 2018, 9:23 PM
DeSl added a subscriber: DeSl.Jan 2 2019, 12:39 PM

Hi all,

Recently, I've checked out some examples under the topic Science, related to Biology and Medicine (for example: ).
There are lots of queries, with the header: #added before 2016-10 . Could I ask what the reason for this is?
And would it be an idea to change this to: Last modified at year-month-date? So we know if the queries are working, and which ones have been updated?

At that point we went through all examples and this was basically a marker. It could be removed/reused now.

I think the query examples should explicitly include even built-in WD prefixes such as wdt: and wikibase:. Missing prefixes render queries invalid and prevent people from simply copy-pasting them into their own environments.

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptAug 3 2019, 12:03 PM