Searching order seems to be broken when searching in topic

AI-generated summary

Moin reported an issue with the search order in a specific topic, where the most liked replies were not displayed correctly. They noticed that even searching ordered by likes, the results were not accurate and instead followed the same order as searching by relevance, most viewed, or latest topic. Moin suspected that the posts were always ordered as they appear in the topic.

joffreyjaffeux confirmed Moin’s analysis, explaining that the issue occurs because results are limited to the first 50 posts, causing incorrect ranking if a post after the 50th has more likes.

The issue is being fixed by a pull request (https://github.com/discourse/discourse/pull/27634), as acknowledged by zogstrip.

Looking at the topic map of DiscoTOC - automatic table of contents - #438 by fbpbdmin, I noticed that something is not right with the most liked replies.


The most liked post shown has 6 likes, but even the last one has 7.

Then I tried to find the three most liked posts by searching ordered by likes, but this did not work either. The results were definitely not the most liked posts. The second result was a small action post which is very unlikely to be one of the most liked posts. Then I noticed that the order was the same as when I chose relevance, most viewed, or latest topic.
Example link for search
Edit: It seems the posts are always ordered like they appear in the topic.

3 Likes

Yes I think your analysis is correct. We limit results to 50 first posts, so any topic with more than 50 posts will have incorrect ranking if a post after the 50th post has more likes than any in first 50 posts.

3 Likes

Thanks a lot for the investigative work :female_detective: @Moin

We were indeed overwriting the “search order” when searching for a specific topic.

This will be fixed by :point_down:

https://github.com/discourse/discourse/pull/27634

2 Likes