User:Smalyshev (WMF)/Suggester

In order to make better prefix search, and bring all variants of prefix search under one roof, we did some refactoring in the search engine implementation, so that various prefix searches now use the same code path and all use SearchEngine class.

The changes are as follows:

SearchEngine gets the following new API functions for SearchEngine: The implementation does not have to implement all three methods differently, they can all use the same code if needed.
 * - implements prefix completion search, returns
 * - implements prefix completion search including variants handling, returns.
 * - basic prefix search without fuzzy matching, etc. to be used in scenarios like special pages search, etc. Returns.

The default implementation still supports  hook but we plan to deprecate it, and CirrusSearch implementation does not use it anymore. Instead, there is a private function:

Which implementations (including CirrusSearch) should implement to provide search results. The services provided by base SearchEngine class that the implementing engine does not have to do include:
 * namespace resolution and normalization.   hook is still supported for engines wishing to implement namespace lookup not featured by the standard implementation.
 * fetching titles for result sets (the implementing engine does not have to fetch titles from DB for suggestions)
 * result reordering to ensure exact matches are on top
 * basic prefix search implementation using the database
 * Special: namespace search implementation

Deprecations
We plan to deprecate  hook and classes    and. We will keep those classes around for basic search fallback implementation and for old extensions, but no new code should be using these classes, instead they should use  APIs described above. Mediawiki code has been already fixed to do that. Extensions implementing search engines should also extend SearchEngine and override the APIs above. CirrusSearch is the example of how to do it.

Show me the code
The patches implementing the refactoring are linked from https://phabricator.wikimedia.org/T121430