Page MenuHomePhabricator

[Story] Maintain Query Examples
Open, MediumPublic

Description

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

Current list: https://www.mediawiki.org/wiki/Wikibase/Indexing/SPARQL_Query_Examples

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: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Find_drugs_for_cancers_that_target_genes_related_to_cell_proliferation ).
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

The SPARQL example page seems currently broken, with the latest queries not properly displayed (currently starting at https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Human_settlements_without_an_article_in_any_language_version_of_Wikipedia), and not properly accessible in the WDQS interface.
Hypothesis : is it because of the large number of the Template:SPARQL used in the same page ?

@Tfrancart Can you add a screenshot about how it looks like for you? I just checked and everything is fine for me, the list is correctly displayed, starting with cats.

@Lea_Lacroix_WMDE : look at the bottom of the page, the latest queries, starting with "Human settlements without an article in any language version of Wikipedia"

Thanks, now I see the same issue.

Bouzinac added a subscriber: Bouzinac.EditedMon, Nov 18, 10:36 PM

Hi there, noticed too the template SPARQL bug. Isn't it simply because the page is too large ?
Shouldn't we break it into subpages ?

  • Simple Queries
  • Showcase Queries
  • etc
So9q added a subscriber: So9q.Fri, Nov 22, 12:44 PM
So9q added a comment.Fri, Nov 22, 12:47 PM

Hi there, noticed too the template SPARQL bug. Isn't it simply because the page is too large ?
Shouldn't we break it into subpages ?

  • Simple Queries
  • Showcase Queries
  • etc

I like this idea. We could add a Lexeme Queries to that list.
Note: This will affect the script that generates the examples-UI in WDQS.

So9q added a comment.Thu, Nov 28, 7:11 AM

I went ahead and split the page. It now has 3 subpages that should be scraped as well.

We recently changed how example loading works (there’ll be an announcement with more information soon), and one consequence of that is that examples which don’t show up in the parsed wikitext – in this case, because the parser’s “post-expand include size limit” was exceeded – no longer load as examples in the query service UI.

But while I think splitting out some subpages makes sense, I don’t think we should scrape those. To me this issue means that the list of examples is simply too long, and instead of working around it by loading the examples from an ever-increasing list of pages, we should decide which queries we actually want to show on query.wikidata.org, and only include those on the main example page. (That doesn’t mean there can’t be other wiki pages with more examples, of course.)