We'd like to give users the option, when adding a template to an article via TemplateData, to search by category as well as the template title
So, for example, there could be a toggle option beside the search bar that, when clicked, opens another search box for searching in categories as well as by title. When the user starts typing in the 2nd search box its dropdown will be populated with "template categories" (where a "template category" is a category containing templates) - the user can then navigate through categories in that dropdown, and the templates shown in the dropdown for the 1st search box will be only those in the selected categories
The interface for the second search box could look something like the UploadWizard category selection widget:
- When the user starts to type in the 2nd search bar its dropdown will show "template categories" that match the search string, with an arrow beside each
- If the user clicks on the arrow beside any of the categories in the drop down they'll see
- A "back" arrow to navigate to their previous view of the dropdown
- A list of subcategories with arrows beside each
- If the user clicks on any of the subcategories that will be highlighted
- When the user types in the 1st search bar its dropdown will be matches for the search string in the highlighted category in the 2nd search bar
Note that right now there is no way to search for template categories. Even if we know the root template category (e.g. Category:Wikipedia_templates in enwiki) there is no way to know while searching if a particular category is a descendent of that root category (the deepcat search keyword exists, but only goes 5 levels deep)
Possible implementation number 1:
- store whether a category is a template category in the search index
- possibly via a data pipeline that gathers all template categories, and that writes a weighted_tag field to each template category's search index document with a value something like category_contains_templates/true|1
- possibly by creating a magic word that a user can add to a template category page that then gets added to page_props, and then index that in the search index (note that it takes ~16 weeks to re-index, and there would also be questions about how the data should be analysed to be searchable)
- create a new CirrusSearch feature (similar to the hasrecommendation feature) that allows passing a keyword to search so that only template categories will be returned - search queries would look something like /w/api.php?action=query&format=json&generator=search&gsrnamespace=10&gsrsearch=istemplatecategory:1 <search_term>
- update the search queries sent by the UI element(s)
Note that this is a large piece of work, involving:
- a new interface element in TemplateWizard (based on an existing one, but would require both design and engineering work), with new interactivity between the search bars
- either
- a new data pipeline - meaning python scripts (possibly in a new repo), plus a new airflow DAG (and note that cycles in the category graph may be tricky to deal with)
- adding some subset of page_props to the search index
- a new CirrusSearch feature
Note that the original proposal for this (a single search box that can handle categories plus template titles) won't work, because some categories contain thousands of templates, and that would not be display-able in a dropdown
