Page MenuHomePhabricator

Let users sort results by time (older or newer results)
Closed, ResolvedPublic

Description

Results are shown in random order (2018, 2015, 2017....). It would be nice if users could sort the results by date/time (at least by the timestamp for the most recent edit).

Use case: I want to search for a specific phrase related to my project to see if there is any discussion about it that I missed on the wiki.

Screen Shot 2018-06-25 at 1.15.54 PM.png (1×1 px, 383 KB)

The dates (highlighted in red) shown beneath the results are the timestamps of the last time the page was edited. Since my project was fairly recent, I am not interested in seeing results from 2015 or 2016. It'd be nice if we could have an option to sort the results by date time or something like filter results from the last 6 months/last 1 year etc.

Event Timeline

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

I've been considering requesting something like this myself, but I realize it may be difficult. I expect the primary use case is searching talk pages. I assume using the date of an edit itself is infeasible, but maybe catching standard signature timestamps could be viable?

It would be a major help even if just one date (the most recent timestamp) was used for the entire page. Most discussions pages cover a relatively constrained timespan. That would be enough to narrow down a search to recently active pages, or to specifically look back for pages archived some time ago.

The last-edited date for the page might be usable, although maintenance edits may unhelpfully reset the page as recent.

It would be a major help even if just one date (the most recent timestamp) was used for the entire page. Most discussions pages cover a relatively constrained timespan. That would be enough to narrow down a search to recently active pages, or to specifically look back for pages archived some time ago.

That's what I was looking for. Like sometimes I'm searching for a recent feature that was introduced or a recent event that occurred and I'm only interested in active pages having that phrase.

@Niharika and @Alsee thanks for the feedback! Do you maybe have a concrete example (including screenshot) what you were looking for and which of the entries you wished to be at which position? Just to make sure we understand everything correctly :)

@Lea_WMDE I updated the description to add more information. Thanks! :)

Vvjjkkii renamed this task from Let users sort results by time (older or newer results) to isaaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from isaaaaaaaa to Let users sort results by time (older or newer results).Jul 2 2018, 4:44 AM
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.

@Lea_WMDE I'll make up a typical example search I'd use. Here's a search for "short description" in namespace Wikipedia or Wikipedia talk.

The search results have a timestamp in green, which I assume is the last-edit date. The simplest thing would be to let me sort, or reverse-sort, by that date. Three use cases:

For the last year and a half, there have been many discussions relating to the Wikidata short description, and replacing it with a local description. If I'm trying to find a specific discussion on that topic, anything prior to 2017 is not relevant.

If there are any new discussions on the topic, ones I didn't know about, they'll be the first results. That's a great use case, I didn't even have that in mind originally.

On the other hand if I'm looking for some old discussion using "short description" in some completely different context, then all of those 2017/2018 hits are unwanted noise. I could either reverse the sort, or I could quick skip down to 2016-and-earlier.

This kind of search result would probably disregard any-and-all other sorting criteria.

I'll also cite a detail which would probably require black magic. I don't realistically expect you to deal with this. Skimming through those search results, one of the hits was Wikipedia:Articles_for_deletion/Log/2005_April_7. If you look at the history of that page, exactly 100% of the content is from 2005. However a bot made a maintenance edit in 2013‎, which was then reverted. Those edits are irrelevant noise. It would be most impressive if you found a way to sort that as 2005.

FWIW we can provide results sorted by the last edit in the api, this is strictly the last edit. This was implemented at the hackathon in Barcelona. We could invent an addtional, perhaps last non-minor edit, timestamp. But i'm not certain that's going to cover other use cases.

For example: https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&list=search&srsearch=foobar&srsort=last_edit_desc

Extracting timestamps from the wikitext content (such as signatures) and then matching those dates would be a significant undertaking. I suppose we could get an 80% solution relatively quickly, but not having glaring edge cases will be significantly more work. This isn't necessarily a search specific task though, what needs to be done in some php code that takes in a ParserOutput (to fit the current internal api's, although wikitext is also doable) and emits a list of dates involved. The 80% solution is probably some regular expressions, and playing wack-a-mole with language formatting variations. From the standpoint of taking a list of dates into search and sorting or filtering by them, that part is mostly straight forward.

Prefer Recent is interesting, but it's no help for key use cases. If I know a discussion happened in approximately May 2016 and there are thousands of search hits, I can't find it.

I just had another idea. I haven't deeply thought it through, but in many cases sorting by date of page creation would be quite effective in finding content from a specific time frame. The main use cases I have in mind tend to involve community process pages. Those pages are often either active for limited time span (i.e. Article For Deletion pages), or they archive on a regular basis (i.e. Village Pump and many Talk pages). In those cases the date of page creation is very closely bound to the date of the content I seek.

If we can add two options, I think "Prefer Recent" and "sort by page creation date" effectively covers the range of use cases.

would adding a "prefer recent" option solve the issue?

It's definitely a help but as @Alsee points out, there are still cases where it's not as good.

Aside, it'd be nice to have options like prefer-recent available under the search bar so people can find them.

Note: This is now possible to do in normal searches via tweaking the search URL, per work on T40403. I've mentioned it in the docs.
It would be great to have (some? all?) of these Help:CirrusSearch#Explicit sort orders features added to the Advanced Search interface for easy access. Cheers!

Change 510934 had a related patch set uploaded (by Tonina Zhelyazkova; owner: Tonina Zhelyazkova):
[mediawiki/extensions/AdvancedSearch@master] Add Sorting order section to Advanced Search panel

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

Trizek-WMF subscribed.

When will it be deployed? When ready, please move it to "Announce in next Tech News" on the User-notice board.

Just a thought.
In my case I am searching for a file on Wikimedia Commons having some search terms and the file should have been uploaded only after 2019 January 1.
Is this case possible with the fix?

@Jnanaranjan_sahu This ticket is about sorting the results retrieved from their search terms, in order of certain date fields instead of 'relevance'. It is not about making the dates themselves search terms.

Change 510934 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Add Sorting order section to Advanced Search panel

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

Text "Sort by" and separate texts for options that follow ("relevance", "edit date" and "creation date") are a bit inconvenient to translate as I'd like to reverse the order of these texts. May I suggest rewording the first text as "Sort by $1" so that position of the option variable can be adjusted per translation. Or, perpahs, to add further flexibility in translating, full phrase ("Sort by relevance") in single message might be even better.

In T197525#5358889, @Pikne wrote:

Text "Sort by" and separate texts for options that follow ("relevance", "edit date" and "creation date") are a bit inconvenient to translate as I'd like to reverse the order of these texts. May I suggest rewording the first text as "Sort by $1" so that position of the option variable can be adjusted per translation. Or, perpahs, to add further flexibility in translating, full phrase ("Sort by relevance") in single message might be even better.

+1, see related docs/explanation at https://www.mediawiki.org/wiki/Localisation#Avoid_fragmented_or_'patchwork'_messages

Lea_WMDE claimed this task.

Change 626179 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/AdvancedSearch@master] Don't put default …&sort=relevance in the URL

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

Change 626180 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/AdvancedSearch@master] Fix broken message for unknown sort orders

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

Change 626180 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Fix broken message for unknown sort orders

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

Change 627230 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/AdvancedSearch@master] Programmatically use sort method messages when they exist

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

Change 626179 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Don't put default …&sort=relevance in the URL

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

Change 627230 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Programmatically use sort method messages when they exist

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