Page MenuHomePhabricator

Sortable search results
Closed, ResolvedPublic5 Estimated Story PointsFeature

Description

When getting the search results it is possible to see some data of the article. It would be great to be able to sort the article based on it, especially on date, but, size and alphabetical would also be useful.


Version: unspecified
Severity: enhancement
See Also:
T18237: Sort results by date
T64879: CirrusSearch: Allow users to search for pages modified "recently"

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

For what it's worth, the IFLA Statement of Principles 7.2 state:

When searching retrieves a large number of [results], results should be displayed in some logical order convenient to the [search] user [...]. The user should be able to choose among different criteria: date of publication, alphabetical order, relevance ranking, etc.

Hi @Ainali - were you able to solve this issue with a user script? If so, we might be able to put that information somewhere for others to use.

In the API this is now partially working!

@EBernhardson How complicated is it to make these URL parameters available for the default website search? (ideally for eventual inclusion in the Advanced Search interface)

@Quiddity I already hacked in a query parameter, sort, that is usable in Special:Search. I'm not sure how much work it would be to wire up AdvancedSearch with this, but there is a ticket already: T197525

@Quiddity I already hacked in a query parameter, sort, that is usable in Special:Search. I'm not sure how much work it would be to wire up AdvancedSearch with this, but there is a ticket already: T197525

Fabulous! Thanks. I've mentioned it in the docs, and will mention it explicitly in that other task.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:14 AM
Aklapper removed a subscriber: bzimport.

Sorting by alphabetical would be great.

@karl-police: See previous comments here why that is not technically feasible.

@karl-police: See previous comments here why that is not technically feasible.

which one? and does it talk about alphabetical sort order?

Sorting by alphabetical would be great.

If what you're trying to do is something like "give me all the pages that contain x, and order them alphabetically" then you're better off using a query engine like Quarry. Then you have even more power than search can provide you. The site search is mostly intended for simple user searches, with some advanced syntax thrown in to serve use cases before easily accessible query engines like Quarry existed.

Gehel set the point value for this task to 5.

Copying comment from merged task:

I suspect the underlying technology is now sufficient to support alphabetical sorts (although we would have to evaluate it to be sure). The main sticking point in Cirrus today is going to be that the way we define keyword fields does not allow doc_values to be enabled. We would need to migrate all the existing fields with the keyword tokenizer to instead use the keyword type along with normalizers, which then allows us to enable doc_values on appropriate keyword fields. Once the index mapping is in place the new sort is only a few lines of configuration in Cirrus.

Change #1197705 had a related patch set uploaded (by DCausse; author: DCausse):

[search/extra@master] Add truncate_norm

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

Change #1198210 had a related patch set uploaded (by DCausse; author: DCausse):

[search/extra@master] Make the term_freq token filter normalizer compatible

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

Change #1197705 merged by jenkins-bot:

[search/extra@master] Add truncate_norm

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

Change #1198210 merged by jenkins-bot:

[search/extra@master] Make the term_freq token filter normalizer compatible

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

Change #1202084 had a related patch set uploaded (by DCausse; author: DCausse):

[mediawiki/extensions/CirrusSearch@master] Simplify natural sort settings

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

Change #1202084 merged by jenkins-bot:

[mediawiki/extensions/CirrusSearch@master] Simplify natural sort settings

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

Echoing the wish in T403775 (merged here) for sort by page name.

Change #1205130 had a related patch set uploaded (by DCausse; author: DCausse):

[operations/mediawiki-config@master] cirrus: index field to sort on title

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

Change #1198219 had a related patch set uploaded (by DCausse; author: DCausse):

[mediawiki/extensions/CirrusSearch@master] Make keyword fields actual opensearch keyword fields

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

Change #1198219 merged by jenkins-bot:

[mediawiki/extensions/CirrusSearch@master] Make keyword fields actual opensearch keyword fields

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

Change #1205130 merged by jenkins-bot:

[operations/mediawiki-config@master] cirrus: index field to sort on title

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

Mentioned in SAL (#wikimedia-operations) [2025-11-19T08:04:11Z] <dcausse@deploy2002> Started scap sync-world: Backport for [[gerrit:1205130|cirrus: index field to sort on title (T40403)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-19T08:09:32Z] <dcausse@deploy2002> dcausse: Backport for [[gerrit:1205130|cirrus: index field to sort on title (T40403)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-19T08:17:52Z] <dcausse@deploy2002> Finished scap sync-world: Backport for [[gerrit:1205130|cirrus: index field to sort on title (T40403)]] (duration: 13m 42s)

Change #1223660 had a related patch set uploaded (by DCausse; author: DCausse):

[operations/mediawiki-config@master] cirrus: allow title natural sort

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

Change #1223660 merged by jenkins-bot:

[operations/mediawiki-config@master] cirrus: allow title natural sort

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

Mentioned in SAL (#wikimedia-operations) [2026-01-06T14:22:20Z] <dcausse@deploy2002> Started scap sync-world: Backport for [[gerrit:1223660|cirrus: allow title natural sort (T40403)]]

Mentioned in SAL (#wikimedia-operations) [2026-01-06T14:24:28Z] <dcausse@deploy2002> dcausse: Backport for [[gerrit:1223660|cirrus: allow title natural sort (T40403)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-01-06T14:44:30Z] <dcausse@deploy2002> Finished scap sync-world: Backport for [[gerrit:1223660|cirrus: allow title natural sort (T40403)]] (duration: 22m 10s)

Support for the following sorting options:

  • incoming_links
  • last_edit
  • create_timestamp
  • title_natural (just recently)

have been added to the backend.
These are available via the action API but unfortunately not via the default Special:Search UI. The Advanced-Search extension enabled on most WMF wikis provide most of these sort options already (except for the last one which might be added via T403775).

I'm going to close this ticket, I would suggest opening new and more focused tickets if what is available now is not sufficient.