Page MenuHomePhabricator

Change template search in TemplateWizard to use standard search API
Closed, ResolvedPublic1 Estimated Story Points

Description

Same as T274903, but for the MediaWiki-extensions-TemplateWizard.

Note this would need a separate feature flag in case we want to hide it.

Implementation:

  • take over search adjustments from 667641
  • adapt variables according to 686436
  • create a new config variable for this extension (e.g. TemplateWizardTemplateSearchImprovements)
  • add * to template search term like in 689070
  • show redirects as part of description in template search 692930 in a separate patch
  • add the "exact match" feature in a separate patch, just as in 693157
  • add tests (like in 667641 )

[WIP] Patch: 697432

Related Objects

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 692930 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/VisualEditor@master] [WIP] Show redirects as part of description in template search

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

Change 693157 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/VisualEditor@master] Guarantee exact match when searching for a template

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

Change 693379 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/VisualEditor@master] Move exact matches to the top in template search

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

Lena_WMDE set the point value for this task to 3.

VE patches seem to be attached to the wrong task.

VE patches seem to be attached to the wrong task.

I fixed that and moved them to T274903.

Change 697432 had a related patch set uploaded (by Svantje Lilienthal; author: Svantje Lilienthal):

[mediawiki/extensions/TemplateWizard@master] [WIP] Change template search in TemplateWizard to use standard search API

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

Change 698475 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateWizard@master] [WIP] Guarantee exact match when searching for a template

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

Change 698571 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateWizard@master] Display redirects when searching for templates

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

Change 697432 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Change template search in TemplateWizard to use standard search API

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

Change 698752 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateWizard@master] Remove unused "templateSearchImprovements" field

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

Change 698752 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Remove unused "templateSearchImprovements" field

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

Change 698475 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Guarantee exact match when searching for a template

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

Change 698571 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Display redirects when searching for templates

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

lilients_WMDE updated the task description. (Show Details)
lilients_WMDE moved this task from Review to Demo on the WMDE-TechWish-Sprint-2021-05-26 board.
Lena_WMDE changed the point value for this task from 3 to 1.Jun 9 2021, 11:29 AM

Needs to be backported.

  • show redirects as part of description in template search 692930 in a separate patch

seems to be not working at the moment, he notice in the search results is missing. See:

TWizardRedirect.png (609×704 px, 27 KB)

I did a quick test: https://simple.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox#action=templatedata&format=json&includeMissingTitles=1&lang=en&generator=search&redirects=1&gsrsearch=citeweb&gsrnamespace=10&gsrlimit=1&gsrprop=redirecttitle. It looks like the "redirecttitle" we need gets lost when the "search" API is used as a "generator". This might be a bug in core, or just something it can't do.

The redirects are there when using prefixsearch, but in another format: https://simple.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox#action=templatedata&format=json&includeMissingTitles=1&lang=en&generator=prefixsearch&redirects=1&gpssearch=citeweb&gpsnamespace=10&gpslimit=1

One partial fix is to use the redirect information from the 2nd exact match query and retroactively add the information to the results of the 1st query. This will at least fix what we can see in the screenshot.

I will look into the "generator" code tomorrow.

I also noticed that the order is different from the order in VisualEditor. The reason is the same: When search is used as a generator, the result appears to be ordered by page ID. The original order by relevance is lost.

Change 699160 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateWizard@master] Fix order template title → redirect → description

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

Change 699203 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateData@master] Fix TemplateData API not properly working with a generator

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

Change 699211 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/core@master] [POC] Retain result order when using an API as a generator

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

I found where the order gets lost: In \ApiPageSet::initFromTitles() somewhere at line #945 is the actual database SELECT executed. It contains a WHERE with all the page titles listed. The titles are still in the correct order in the WHERE clause. But MySQL doesn't care about this. There is no ORDER BY. The results are ordered in whatever order MySQL feels like.

To fix this we either need to force the SELECT to retain the specific order (a proof of concept for this is in https://gerrit.wikimedia.org/r/699211), or restore the order after the SELECT was executed.

This really is a core bug. Not sure how to tag this.

Change 699767 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/TemplateWizard@master] Restore original template search result order

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

Change 699211 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/core@master] [POC] Retain result order when using an API as a generator

Reason:

Not needed, see Ic7eabcf.

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

Turned out to be easier than expected: The patch https://gerrit.wikimedia.org/r/699203 will not only make redirect information available. There is also an "index" field. We can use this to restore the original search result order, done via https://gerrit.wikimedia.org/r/699767.

Change 699160 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Fix order template title → redirect → description

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

Change 699203 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Fix TemplateData API not properly working with a generator

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

Change 699767 merged by jenkins-bot:

[mediawiki/extensions/TemplateWizard@master] Restore original template search result order

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