Page MenuHomePhabricator

Add configuration variable to set default search results sorting
Open, Needs TriagePublicFeature

Description

Feature summary

Please implement a configuration variable to set the default method of how search results are sorted: "relevance" (current hardcoded default), "title_asc", "title_desc"

Use case(s)

Within the source, I found the following function:

/**
 * Set the type of sort to perform.  Must be 'relevance', 'title_asc', 'title_desc'.
 * @param string $sort sort type
 */
public function setSort( $sort ) {
    $this->sort = $sort;
}

And, I see the variable used within the source as well:

/**
 * @var string sort type
 */
private $sort = 'relevance';

However, in looking through the extension's configuration variables HERE, I do not see an existing configuration variable for changing the default behavior of the extension.

Benefits

I think the benefits are pretty obvious, and it seems a pretty straightforward feature to implement. The main benefit I see would be to avoid users from needing to manually edit the source files if they do not want the default to be "relevance".

For what it's worth, my users are requesting that the sorting be "by title" because I believe that's what they were used to with the default Mediawiki Search (before I added the CirrusSearch extension.) In other words, I'm making this request because my users want it -- not just for the sake of asking for something new. :)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Saerec would you be interested in posting a patch for this? We'd be happy to review. Do I understand correctly that you're looking to support this on another wiki?

@dr0ptp4kt I'm a C++ coder with some php experience, so I'll give it a whirl. Perhaps I can find a patch where a configuration variable was added and it should be similar.

And, yea, this is for https://www.windrep.org , the wiki I maintain.

Thanks!

Great, thanks! If you are looking to discuss along the way you can find Search Platform on the #wikimedia-search channel on Libera IRC.

I got an error trying title_asc, and the message suggested title_natural_asc, which worked. Can someone explain the reason for the label change? What's wrong with "title_asc", and can that be aliased to the new value, as it is a guessable label while the actual one is not? (Ditto title_natural_desc.) Thanks.