Page MenuHomePhabricator

MediaWiki REST API Search results should resolve redirects
Open, MediumPublic5 Estimated Story PointsBUG REPORT

Description

The issue also impacts the old legacy opensearch API, ( T296225) however that can be fixed by changing query parameters.

The API https://en.wikipedia.org/w/rest.php/v1/search/title?q=Tale%20of%20two%20cities&limit=10 returns redirect titles rather than resolving them.

Description

In new vector we introduced thumbnails and article descriptions for the search autocomplete results. For pages with redirects we show the redirect in the autocomplete results, rather than the page itself, which makes for a somewhat confusing experience because the redirects don't have thumbnails or descriptions. For example:

what I seewhat I expect to see
image.png (302×1 px, 57 KB)
image.png (302×1 px, 85 KB)
image.png (434×1 px, 121 KB)
image.png (434×1 px, 150 KB)
image.png (1×1 px, 426 KB)
image.png (1×1 px, 544 KB)

Event Timeline

Pchelolo renamed this task from RESTBase Search results should resolve redirects to MediaWiki REST API Search results should resolve redirects.Nov 29 2021, 8:04 PM

Just for consideration, there are some examples of redirects that may not be obvious or may look weird. In the examples below where A → B, starting to type A would result in autocomplete text and images for B.

Thelma Riley → Ozzy Osbourne

Corn → Maize

JFK → John F. Kennedy

Москва → Moscow

தமிழ் → Tamil Language

→ ↑ → [redirects to] Tsk Tsk Tsk

The Free Encyclopedia → Wikipedia

Anakin Skywalker → Darth Vader

I don't think this is necessarily a problem, and there may be ways of making it less potentially confusing in these cases: e.g. when there is a redirect, suggesting something like "Thelma Riley (Ozzy Osbourne)"

I think adding an additional property to each result in https://en.wikipedia.org/w/rest.php/v1/search/title?q=Tale%20of%20two%20cities&limit=10 would allow clients to handle this without confusion.

So instead of

{
  "pages": [
    {
      "id": 1516162,
      "key": "Tale_of_two_cities",
      "title": "Tale of two cities",
      "excerpt": "Tale of two cities",
      "description": null,
      "thumbnail": null
    }
  ]
}

In this case matchedtitle would always be the resolved redirect (and often identical to "title").

{
  "pages": [
    {
      "id": 1516162,
      "key": "Tale_of_two_cities",
      "title": "A Tale of Two Cities",
      "matchedtitle": "Tale of two cities",
      "excerpt": "Tale of two cities",
      "description": null,
      "thumbnail": null
    }
  ]
}
sdkim triaged this task as Medium priority.Dec 9 2021, 5:10 PM
sdkim set the point value for this task to 5.
sdkim moved this task from Backlog to Ready/Groomed on the API Platform board.

Change 753810 had a related patch set uploaded (by Nikki Nikkhoui; author: Nikki Nikkhoui):

[mediawiki/core@master] WIP: Add matched_title field to /search/page results

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