Before and after are not implemented right in search

AI-generated summary

Users reported a bug where the ‘after’ and ‘before’ search filters in Discourse are not functioning correctly. JagWaugh noted that searching with ‘after:2018-07-18’ still returns 37 results, and observed that the search interface mistakenly swaps ‘after’ for ‘before’ upon opening a link — likely an unrelated UI bug shown in screenshot. sam recalled that the original implementation used relative days (e.g., ‘after:5’), and speculated that date-based syntax was introduced incorrectly, causing confusion in the advanced search UI. JagWaugh clarified that while the initial display is misleading, the actual result list is correct — and that manually triggering a search then navigating back fixes the display. The issue was later fixed by the Discourse team, with thanks to JagWaugh for reporting it.

@Gunnar is travelling today, so it will be a while until he can provide that info.

A search for “after:2018-07-18” (i.e. after tomorrow) still yields the same 37 hits.

I also noticed that opening the link here:

Changes it from “after” to “before”, which I presume is an unrelated bug.

3 likes

Yeah this is pretty dodge… back in the day my implementation was after:5 and before:5 where 5 is the number of days ago.

Somehow a date snuck in … somehow the advanced UI gets confused between before and after.

1 like

It shows as the screen shot when the tab opens, hitting refresh doesn’t change anything, but hitting the search button then back corrects it.

EDIT (not enough coffee yet): The list of hits that it lands with, before clicking anything, is apparently correct.

5 posts were merged into an existing topic: Post date oddities, search

Fixed in

https://github.com/discourse/discourse/commit/bd66fbef7fd6d6259bedc37295b1174f6e3771c9

Thanks for reporting @JagWaugh

5 likes