Page MenuHomePhabricator

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

Description

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

  • Go to https://en.wikipedia.org/wiki/?useskin=vector-2022
  • 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 subscribed.

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(): https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/specials/SpecialSearch.php$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: https://codesearch.wmcloud.org/search/?q=%5Cbwprov%5Cb. As far as I can tell this doesn't affect what we are looking at here.

Advanced-Search does have a feature called redirectToNamespacedRequest: https://phabricator.wikimedia.org/diffusion/EASR/browse/master/includes/Hooks.php$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.

Jdlrobson subscribed.

Need some clarity here on precisely what needs to happen. My understanding is that search result routes through Special:Search for instrumentation purposes. Might be helpful to get a few people in a room to work out what exactly needs to be done here.

Next steps here: Discuss in the DST/Web sync tomorrow -- I have added this to the agenda

This relates to Special:Search so we don't believe this should be in the web team backlog.