Page MenuHomePhabricator

mw.wikibase.entity:getBacklinks (lua API in wikibase client)
Open, NormalPublic

Description

Use cases:

  1. I want to be able to automatically produce pages like https://en.wikipedia.org/wiki/Zaikin (based on P734 sentences in wikidata)
  2. I want to be able to automatically produce lists like https://en.wikipedia.org/wiki/List_of_Aloe_species (based on P171 statements in wikidata)

I think I have everything to implement that except for ability to get all elements, that links to the specific one (similar to https://www.wikidata.org/wiki/Special:WhatLinksHere/Q18390678). This functionality exists in Mediawiki API (query/links), but does not exists in wikibase client. The output of mw.wikibase.entity:getBacklinks() can be just a table of qids or (preferrably) qids+propertyIds

Event Timeline

Ghuron created this task.Jan 19 2018, 12:37 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 19 2018, 12:37 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptJan 19 2018, 1:49 PM
Uzume added a subscriber: Uzume.EditedJan 20 2018, 8:44 PM

This seems like a more generalized version of T99899 (see also T149108).

I like the idea of a Wikibase client reverse claim query interface that returns entity IDs (but I am not sure it makes sense to hang this off an Lua table serialized entity object). One of the key tenets of Wikidata was always to provide a means to create automatically generated lists of related items.

This seems like a more generalized version of T99899 (see also T149108).

Well, although I can some similarities between this one and T99899, I believe there are different use cases involved. Lookup for external identifier is mostly needed in javascript (e.g. notify user that wikidata instance with the same imdb-id already exists) and can be implemented either via Markus resolver or directly via sparql endpoint (e.g. https://ru.wikipedia.org/w/index.php?diff=84445799). I can imagine some use cases where it would be nice to have it in lua (e.g. for additional decoration of wikipdate articles), but its exotic stuff. In contrast, building lists andbased on wikidata is more straightforward case and must be pure severside (for performance reasons), so I'd see a need for backlinks in lua.

Uzume added a comment.Jan 23 2018, 4:02 PM

Well, although I can some similarities between this one and T99899, I believe there are different use cases involved. Lookup for external identifier is mostly needed in javascript (e.g. notify user that wikidata instance with the same imdb-id already exists) and can be implemented either via Markus resolver or directly via sparql endpoint (e.g. https://ru.wikipedia.org/w/index.php?diff=84445799). I can imagine some use cases where it would be nice to have it in lua (e.g. for additional decoration of wikipdate articles), but its exotic stuff. In contrast, building lists andbased on wikidata is more straightforward case and must be pure severside (for performance reasons), so I'd see a need for backlinks in lua.

That may or may not be true but this issue seems extremely similar to that requested in T149108 which was closed as a duplicate of T99899 and thus I drew the relation between the two.

hoo moved this task from Incoming to To do later on the Wikibase-Lua board.Apr 12 2018, 1:56 PM
Ghuron triaged this task as Normal priority.Apr 12 2018, 8:57 PM
Ghuron added a project: patch-welcome.

I'd like to explain another scenario, where this functionality can be useful. Ru-wiki infoboxes sometimes add categories to the corresponding articles. Sometimes we do this based on wikidata, but we are pretty much limited to a few cases, defined in P1465, P1792, P1464 or very special usage of P910 (e.g. if astronomical object belongs to some constellation). If I want to automatically place categories like Q8454640 to the films, directed by James Marsh, I probably would need a designated property. Alternatively I should be able to do it via extracting items that has P971:Q2720543 and simultaneously P971:Q29017630. This may sound like reinventing SPARQL queries, but getting results of getBacklinks(Q2720543) and getBacklinks(Q29017630) and performing list intersection in lua would work for me.

Townie added a subscriber: Townie.May 25 2018, 8:29 AM