Page MenuHomePhabricator

Vector search does unnecessary redirects (including a double redirect) when clicking a search result
Open, HighPublicBUG REPORT


Steps to replicate the issue (include links if applicable):

  • Go to
  • Open the inspector. Go to the Network panel, and set the filter to "Doc"
  • Type "Albert" in the search bar
  • Click on the search result for "Albert Einstein"
  • This takes you to the "Albert Einstein" article
  • Type "Albert" in the search bar again
  • Click "Search for pages containing Albert" at the bottom of the results
  • This takes you to the search page for "Albert"

What happens?:
When clicking the Albert Einstein result:

When clicking the "Search for pages containing Albert" result:

What should have happened instead?:
There should be only one redirect (in the first case), or ideally no redirect at all (in both cases).

Software version (skip for WMF-hosted wikis like Wikipedia): Current production (1.40.0-wmf.10)

Other information (browser name/version, screenshots, etc.):

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Gehel triaged this task as Medium priority.Nov 21 2022, 4:23 PM
Gehel added a project: Advanced-Search.
Gehel moved this task from needs triage to elastic / cirrus on the Discovery-Search board.
Gehel added a subscriber: Gehel.

The redirect seems to be related to AdvancedSearch. Some clean up needs to happen in the order of operations.

Gehel raised the priority of this task from Medium to High.Nov 21 2022, 4:23 PM
Gehel lowered the priority of this task from High to Medium.
Gehel raised the priority of this task from Medium to High.
thiemowmde added subscribers: thiemowmde, WMDE-Fisch.

Pretty much all of these extra redirects are because of MediaWiki core's resources/src/mediawiki.searchSuggest/searchSuggest.js. It actually creates links that point back to Special:Search instead of the search result. The final redirect to the article is done in SpecialSearch.php via a feature named goResult():$217. I honestly don't understand why. I mean, what SpecialSearch.php does is fine. But why doesn't searchSuggest.js trust the opensearch API and links directly to the articles? What's the point?

The wprov parameter is some "SearchSatisfaction" instrumentation and seems to be set by Vector (legacy skin) and/or CirrusSearch: As far as I can tell this doesn't affect what we are looking at here.

Advanced-Search does have a feature called redirectToNamespacedRequest:$53. The motivation is described in T217445: AdvancedSearch should always create URLs unambiguous about the namespaces being used.

Problem is: There is no way AdvancedSearch can know that the link to title=Special:Search&search=Albert+Einstein is actually pointless and will not end on a search result page but in a redirect to the article. AdvancedSearch would need to re-implement the exact goResult() logic from SpecialSearch.php. Which is something I wouldn't recommend.

history.pushState() comes to mind, something we already use a lot. I think it's possible to redo the AdvancedSearch feature this way, without any redirects.

Other ideas?

It's not just searchSuggest.js, I filed this task about the behavior in the new Vue-based implementation of the search bar in Vector-2022, which doesn't use searchSuggest.js but constructs similar URLs.

Removing Search team from this. Please ping us if we need us.