FIX: Apply category priority for empty query (PR #9516)

This PR is to apply category search priority when searching with empty query without specified order.

Per https://meta.discourse.org/t/search-priority-for-categories-dont-work-with-empty-search-query/143642

GitHub

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/search-priority-for-categories-dont-work-with-empty-search-query/143642/3

Could you add some tests for this?

Sure, I will add tests for this later.

Could you add some tests for this?

Sorry for the late reply. I have added some tests, please check my update :smile:

Thanks, this looks good now! I’m going to merge it.

@blueworrybear : Does this fix ensure proper behavior of queries like this too? https://meta.discourse.org/search?q=status%3Asingle_user%20status%3Aopen%20status%3Aunsolved%20order%3Alatest_topic

That was actually my original question when I said empty query (but with search parameters).

@blueworrybear : Does this fix ensure proper behavior of queries like this too? Search results for 'status:single_user status:open status:unsolved order:latest_topic' - Discourse Meta

That was actually my original question when I said empty query (but with search parameters).

@GokulNC

The queries you posted will still sort by the topic created time.

The topics will be sorted by priority only if the order is not specified.

For example:

https://meta.discourse.org/search?q=status%3Asingle_user%20status%3Aopen%20status%3Aunsolved

This query will sort topics with priority.

Got it, thanks a lot !! :slight_smile: