Page MenuHomePhabricator

Change how SpecialSearch/SearchEngine handles the 'prefix' URI param set by the InputBox extension
Closed, ResolvedPublic

Description

The InputBox extension allows to pass a prefix URI param to the SpecialSearch page.
The purpose of this prefix param is to limit searches to pages whose title is starting with this prefix value. This is useful to provide ready-to-use search boxes to search archive pages for example or pages within a particular tree of subpages.

This prefix param is only supported by CirrusSearch and the deprecated lucene-search extension.

To implement this feature:

  1. a new URI param has been added to SpecialSearch,
  2. this var is then passed to SearchEngine by SpecialSearch
  3. SearchEngine::transformSearchTerm is called and will, in the case of CirrusSearch, append a prefix keyword to the query
  4. SpecialSearch then calls searchText with the modified search query

This has imo multiple drawbacks:

  • Having to call SearchEngine::transformSearchTerm() prior to calling searchText() seems like an unnecessary step that is easy to miss. This should be handled internally by the SearchEngine.
  • Appending and munging the user query might lead to unexpected behaviors, while this works for simple word queries there are no guarantee that the generated query will be valid as we start to support better boolean logic in cirrus search
  • This changes the original query sent by the user and gives a false impression that the prefix keyword is heavily used by users.

This task is about proposing to change how this works and at the same time address some tech debt by deprecating the SearchEngine::transformSearchTerm method.

To illustrate this here is as an example using the MOS page on the english wikipedia:

Searching for bold opens the Special:Search page with the user query being suffixed with the keyword prefix:Wikipedia:Manual Of Style :

The suggested behavior is to not change the user query but add a hint in the UI (to be properly defined) to indicate that the user is searching within pages whose titles start with Wikipedia:Manual Of Style. By clicking the UI hint the user will have the possibility to reset the Special:Search state (i.e. remove the prefix filter).

Note that this UI suggestion is far from being ready, it's just for illustration purposes and was a way for me to test the new back-end code.

A few patches will be attached to this ticket to clarify the impact on the code, they should not be merged without discussing the impact of adding a new UI component to Special:Search. I'm also pinging the AdvancedSearch extension since it might have some impact there as well.

To sum up, the state of this ticket is to start to discuss about this suggestion.

Details

Related Gerrit Patches:

Event Timeline

dcausse created this task.Jun 27 2018, 11:45 AM
Restricted Application added projects: TCB-Team, Discovery. · View Herald TranscriptJun 27 2018, 11:45 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
dcausse updated the task description. (Show Details)Jun 27 2018, 11:47 AM
dcausse updated the task description. (Show Details)Jun 27 2018, 11:51 AM

Change 442288 had a related patch set uploaded (by DCausse; owner: DCausse):
[mediawiki/extensions/CirrusSearch@master] [DNM] Move SearchEngine::prefix support in searchText

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

Change 442289 had a related patch set uploaded (by DCausse; owner: DCausse):
[mediawiki/core@master] [DNM] Deprecate usage of SearchEngine:transformSearchTerm

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

Hi @dcausse, thanks for bringing this up!
With AdvancedSearch you would get to the same result, if the namespace was added correctly, and the "subpage of" keyword was being used. I personally find the prefix keyword a bit hard to handle, since it is hard to combine it with other keywords, and contains the namespace definition in the keyword syntax. So I am wondering, if it would also be possible to replace prefix by decomposing it into a namespace that is being selected (and visibly shown, also in the current interface), and the rest being past to "subpageof".

dcausse updated the task description. (Show Details)Jun 28 2018, 5:47 PM

@Lea_WMDE extracting the namespace and prepare the namespace filters according to the prefix param that is passed will have the negative impact of opening the namespace filter (very wide on vanilla Special:Search).

The approach I'm trying to take at the moment is to move this logic into the SearchEngine internals and not relying on the syntax, so the prefix keyword would not be used in the case of custom search boxes like MOS search.

I've updated the screenshot of my suggestion, now I include this new UI hint in the page subtitle :

But in the end I'd love to find a way to hook that up with the AdvancedSearch extension (when enabled) so that we could pre-populate your own filters (using subpageof) like you suggest.

So do I understand right that the proposal is to keep the prefix URL param, but instead of handling it by messing with query string, handle it by adding a filter in search context? If so, I think it's the right thing to do.

@CKoerner_WMF would you have some time to probe this proposal with community members?

So do I understand right that the proposal is to keep the prefix URL param, but instead of handling it by messing with query string, handle it by adding a filter in search context? If so, I think it's the right thing to do.

Yes that is exactly the plan.

Elitre added a subscriber: Elitre.Jul 5 2018, 10:46 AM

@CKoerner_WMF would you have some time to probe this proposal with community members?

Hi there Erika!
You may find https://office.wikimedia.org/wiki/Community_Relations/Support_requests#How_to_request_our_assistance helpful in guiding your request for support from our team. TY!

This comment was removed by dcausse.
dcausse claimed this task.Jul 5 2018, 2:00 PM
Izno added a subscriber: Izno.Jul 17 2018, 5:52 AM

Change 442288 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Move SearchEngine::prefix support in searchText

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

Change 442289 merged by jenkins-bot:
[mediawiki/core@master] Deprecate usage of SearchEngine:transformSearchTerm

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

Pipetricker renamed this task from Refactor how SpecialSearch/SearchEngine handles the 'prefix' URI param set by the InputBox extension to Change how SpecialSearch/SearchEngine handles the 'prefix' URI param set by the InputBox extension.Jul 21 2018, 2:37 PM
debt closed this task as Resolved.Jul 31 2018, 5:48 PM