Hi!
I'd like to describe the refactoring we are doing on SearchEngine/Prefix
search. The goal of it is to bring prefix search into SearchEngine API
and use the unified API for prefix searches, which will also allow to
use new ElasticSearch completion suggester in many places where prefix
search is done.
Please comment if you see any problem in this or have any suggestions.
The current plan is as follows:
1. SearchEngine gets the following new API functions:
public function defaultPrefixSearch( $search );
public function completionSearch( $search );
public function completionSearchWithVariants( $search );
defaultPrefixSearch is for simple prefix searches (namespace lists,
special pages, etc.).
completionSearch* is for completions that need scoring, fuzzy matching,
and so on.
2. There's also internal function:
protected function completionSearchBackend( $search )
That is what SearchEngine implementation (like CirrusSearch) will
override. SearchEngine base class deals with namespace handling, result
ordering, etc.
3. TitlePrefixSearch and StringPrefixSearch will be deprecated (but stay
in code almost unchanged for now) and use of SearchEngine APIs is
recommended, such as SearchEngine::defaultPrefixSearch() or
completionSearch() depending on whether simple or advanced handling is
desired.
4. Hooks PrefixSearchBackend and PrefixSearchExtractNamespace will be
deprecated, and overriding completionSearchBackend() and
normalizeNamespaces() in SearchEngine is recommended instead. For now,
these hooks will be supported by base SearchEngine implementation, but
not by CirrusSearch.
The task for this is
https://phabricator.wikimedia.org/T121430, it also
links the patches as they are now (still work in progress).
--
Stas Malyshev
smalyshev(a)wikimedia.org