Page MenuHomePhabricator

Template search not finding exact matches in VE
Open, Needs TriagePublicBUG REPORT

Description

From a user report – sorry for the lazy bug filing, can tidy up when not out of hours...

00:58 <HuBoro> Hi all, in the huwiki there is a problem with templatediscovery in the Visual editor where it doesn't show exact matches, is this a problem any of you heard about and/or where should I file a bug report?
01:00 <HuBoro> Specifically, user opens the visual editor, tries to search for Szerkeszt, which does not display that template, but displays Szerkesztf. We found a workaround, that if we switch to the old source editor and switch back to the visual editor, it shows up. The issue is also present for Szülhal and Egyért (where Egyért0, Egyért2, and Egyért3 do
01:00 <HuBoro> not show up)
01:07 <HuBoro> 1. The issue is only present if Visual editor is opened first. If the page is refreshed, it occurs again. It's not present if the source editor is opened first and then switched to the visual editor.
01:07 <HuBoro> 2. The issue is present regardless the template was favorited or not.
01:07 <HuBoro> 3. The broken templates have no common denominator, initially we thought this might do something with the TemplateData being in /doc and that doc being referred by the hungarian {{Sablondokumentáció}} instead of {{Documentation}}
01:07 <HuBoro> 4.Nullediting and purging the template and template doc does not help.
01:07 <HuBoro> 5.No matter the search key, the template does not show up.
01:07 <HuBoro> 6.Hitting the API directly correctly sends back the results for the templates

Event Timeline

user opens the visual editor, tries to search for Szerkeszt, which does not display that template, but displays Szerkesztf.

Searching for Szerkeszt in TemplateWizard or on Special:TemplateDiscovery gets this API request and search results:

https://hu.wikipedia.org/w/api.php?action=templatedata&format=json&includeMissingTitles=1&lang=en&generator=search&redirects=1&gsrsearch=Szerkeszt*&gsrnamespace=10&gsrlimit=10&gsrprop=redirecttitle

image.png (470×765 px, 50 KB)
image.png (617×723 px, 51 KB)

When searching for the same in the VE template insertion dialog, it's the same request but different results:

https://hu.wikipedia.org/w/api.php?action=templatedata&format=json&includeMissingTitles=1&lang=en&generator=search&redirects=1&gsrsearch=Szerkeszt*&gsrnamespace=10&gsrlimit=10&gsrprop=redirecttitle

image.png (459×691 px, 43 KB)

I'll continue investigating…

thiemowmde added subscribers: WMDE-Fisch, awight, thiemowmde.

When the WMDE-TechWish team implemented the original ve.ui.MWTemplateTitleInputWidget we invested a lot of time trying to find the best possible search API for the task and the best possible combination of options the APIs gave us to play with. See T274903: Change template search in VisualEditor to use standard search API. We ended adding an extra, cheap opensearch API request on top of the normal, CirrusSearch based search request to make sure an exact 1:1 match would always be found, even if CirrusSearch would rank it low. See https://gerrit.wikimedia.org/r/693157 for the first iteration of that code.

It appears like this got lost.

There is a bunch more code in this widget for all the edge-cases we discovered back then and generally for the user's convenience. E.g. how redirects are handled, sorted, and presented. Or to make sure an exact 1:1 match is always at the very top, no matter which of the two API requests found it.

We also did our best to make the search in MediaWiki-extensions-TemplateWizard behave the same as what we did in VE.

Personally, I would advice you to keep all of this code (e.g. extract it into a place where you can reuse it) or ask the WMDE-TechWish team's devs in case the code alone is not self-explanatory enough. Thanks you!

I just realized you did all that. I'm so sorry for my bad comment above. The issue must be something else then.

Yeah I at first assumed it was related to that part as well. But it's weird that there are different results in the different dialogs (actually, I assume I made a mistake when testing yesterday). One thing we've added is the excluding of /doc, /testcases, etc. subpages, so I dunno maybe there's something there that's breaking it.

Meanwhile, a user found another workaround: In the TemplateWizard's search field, type the template name in full and press Enter. This opens up the next step, even if the template doesn't appear in the search results.