[Epic] Allow extensions to register simple keyword features
Closed, ResolvedPublic

Description

Extensions can now register additional fields that will be part of the index but they can't register special syntax to use them inside search queries.

Extensions should be provided a way to register special keywords that can be used to filter and/or rank main search results.

The idea would be to declare a new CirrusSearchKeywordService inside MediawikiServices.
When this service is instantiated it will build a list of the keywords declared by cirrus and then call a hook to allow extensions to register their own.

The base class to implement is SimpleKeywordFeature.

SimpleKeywordFeature allows accessing the SearchContext and provides a way to add new Filters and should provide a way to declare new rescore functions to rerank results.

Everything is mostly ready in cirrus to do this except rescore functions. A way to do it would be add a new array of type FunctionScoreBuilder inside the SearchContext class. Extension could then call

$searchContext->addRescoreFunction( $myFunctionScoreBuilderImplemention );

from their SimpleKeywordFeatures implementation.

The rescore function builder would then need to inspect the searchContext to add these rescore function to the optional_chain.

Currently the rescore builder is completely generic and generate elastic queries by reading a rescore profile. Now the optional_chain would bear a special meaning as it will be the default placeholder for SimpleKeywordFeatures to register their ranking functions.

This will probably involve splitting includes/Search/RescoreBuilders.php which currently contains multiple classes.

In the end everything should be put in place to allow moving includes/Query/GeoFeature.php to the GeoData extension.
Moving to GeoData is not strictly needed but would be a nice proof of concept and a good example for other extensions.

dcausse created this task.Dec 6 2016, 7:26 PM
Restricted Application added a project: Discovery. · View Herald TranscriptDec 6 2016, 7:26 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev claimed this task.Dec 6 2016, 7:39 PM
Smalyshev triaged this task as "Normal" priority.Dec 15 2016, 1:26 AM
Deskana closed this task as "Resolved".Jan 6 2017, 5:44 PM