Page MenuHomePhabricator

Change wbsearchentities to explicitly return display terms and matched term.
Closed, ResolvedPublic8 Estimated Story Points

Description

As a user of screen readers, I want my screen reader the label and description in the correct language in order to understand them well.

Problem:
Right now the wbsearchentities API does not return the language for labels and descriptions. It should. The current behavior is especially problematic when the returned match contains a label and description from a fallback language.

Example:
What the API currently returns with https://www.wikidata.org/w/api.php?action=wbsearchentities&search=%D9%85%D9%84%D8%B9%D8%A8%20%D9%88%D9%8A%D9%83%D9%8A%20%D8%AF%D8%A7%D8%AA%D8%A7&language=ar&uselang=ar&formatversion=2

{
    "searchinfo": {
        "search": "ملعب ويكي داتا"
    },
    "search": [
        {
            "id": "Q4115189",
            "title": "Q4115189",
            "pageid": 4246474,
            "repository": "wikidata",
            "url": "//www.wikidata.org/wiki/Q4115189",
            "concepturi": "http://www.wikidata.org/entity/Q4115189",
            "label": "ملعب ويكي داتا",
            "description": "item for experimenting",
            "match": {
                "type": "label",
                "language": "ar",
                "text": "ملعب ويكي داتا"
            }
        }
    ],
    "success": 1
}

We want something like this:

{
    "searchinfo": {
        "search": "ملعب ويكي داتا"
    },
    "search": [
        {
            "id": "Q4115189",
            "title": "Q4115189",
            "pageid": 4246474,
            "repository": "wikidata",
            "url": "//www.wikidata.org/wiki/Q4115189",
            "concepturi": "http://www.wikidata.org/entity/Q4115189",
            "label": "ملعب ويكي داتا",
            "description": "item for experimenting",
            "match": {
                "type": "label",
                "language": "ar",
                "text": "ملعب ويكي داتا"
            },
            "display": {
                "label" {
                    "language":"ar",
                    "text": "ملعب ويكي داتا"
                },
                "description": {
                    "language":"en",
                    "text": "item for experimenting"
                }
            }
        }
    ],
    "success": 1
}

BDD
GIVEN a call to the wbsearchentities api
WHEN returning a match
THEN the language for the label and description is returned as well

Acceptance criteria:

  • wbsearchentities returns the language for labels and descriptions of returned matches

Note:

  • This should not be a breaking change but we should communicate it.

Original report:
wbsearchentities used to return label, description, and (if matched) aliases in the requested search language (or fallback language of that). This chanegd with T90692, which introduced an internal search interface that would provide the matched term in the search language (or one its fallback languages) and display terms (a label and a description) in the user language (or one of its fallback languages).

wbsearchentities will currently return the label and description in the user language, and the (single) matched term in the "aliases" slot, as plain strings. The rationale for this is the main use case for the "aliases" field: it allows the UI to show why a term was returned as a result to the search. In addition to the old "aliases" field, wbsearchentities now returns a "matched" field with the matched term as a full term structure.

We should add a "display" field, which would contain the full term structures (including the actual language) of the label and description. The old label, description, and alias fields should be deprecated. The Wikibase UI should be changed to only use the "matched" and "display" fields.

Follow-ups:

Event Timeline

daniel raised the priority of this task from to Needs Triage.
daniel updated the task description. (Show Details)
daniel subscribed.
Michael raised the priority of this task from Low to Needs Triage.Feb 9 2022, 5:19 PM
Michael subscribed.

This is a big problem because we cannot properly mark up the language of the label and description in the HTML.

This is also relevant to the ongoing Special:NewLexeme revival hike as it will use this api and especially relevant to the recreation of the Typeahead Searchbox component (this is the little on-wiki search-box) in Codex, see T299682.

We should also consider whether it makes sense to also add the direction of the language to the output. This is generally not required on MediaWiki itself, as we can there look this up on the clientside. But this API might also be used outside of MediaWiki.

karapayneWMDE set the point value for this task to 8.Mar 9 2022, 1:36 PM

Change 771674 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Add 'display' to wbsearchentities response

https://gerrit.wikimedia.org/r/771674

Change 771674 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add 'display' to wbsearchentities response

https://gerrit.wikimedia.org/r/771674

Change 772372 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Use new display part of wbsearchentity response in entity selector

https://gerrit.wikimedia.org/r/772372

Change 772411 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772411

Change 772411 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772411

Change 772361 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@wmf/1.39.0-wmf.1] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772361

Change 772362 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@wmf/1.39.0-wmf.2] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772362

Change 772361 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.39.0-wmf.1] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772361

Change 772362 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.39.0-wmf.2] Add display to wbsearchentities response even if empty

https://gerrit.wikimedia.org/r/772362

Mentioned in SAL (#wikimedia-operations) [2022-03-21T16:44:19Z] <lucaswerkmeister-wmde@deploy1002> Synchronized php-1.39.0-wmf.1/extensions/Wikibase/repo/: Backport: [[gerrit:772361|Add display to wbsearchentities response even if empty (T104344)]] (duration: 00m 53s)

Change 772372 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Use new display part of wbsearchentity response in entity selector

https://gerrit.wikimedia.org/r/772372

Change 772372 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Use new display part of wbsearchentity response in entity selector

https://gerrit.wikimedia.org/r/772372

Change 774428 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseQualityConstraints@master] Add new display member to wikibase.entityselector.search results

https://gerrit.wikimedia.org/r/774428

Change 776167 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/Wikibase@master] 1.38 Release Notes: A info about wbsearchentities change

https://gerrit.wikimedia.org/r/776167

Change 776167 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] 1.39 Release Notes: Add info about wbsearchentities change

https://gerrit.wikimedia.org/r/776167