Experimental topics list filter feature

We have recently introduced an innovative /filter route, enabling more sophisticated filtering of the topics list. Significantly, this marks the initial step towards a unified topic filtering language for both search and filtering. Additionally, the dedicated route for topic list filtering enhances the customizability of the sidebar, as users can now incorporate links as custom section links within the sidebar.

How to turn it on

Enable the experimental_topics_filter site settings in the admin interface.

How it works

The /filter has an input field which users can input a query string to filter through the list of topics.

As an example, category:documentation tag:how-to+email will filter for topics that are in the documentation category tagged with both how-to and email.

Currently this is the list of filters that are supported:

status:open topics that are not closed or archived
status:closed topics that are closed
status:public topics that are not read restricted (eg: belong to a secure category)
status:archived topics that are archived
status:unlisted topics that are not visible
status:listed topics that are visible
status:deleted topics

in:pinned topics that are are pinned (either global or per category pins)
in:watching stuff I am watching - supports (muted,normal,tracking, watching_first_post): allow for filtering down to stuff your are tracking, watching etc. - multiple values can be comma separated
in:bookmarked stuff I’ve bookmarked

category:bug topics in the bug category AND all subcategories
=category:bug topics in the bug category excluding subcategories
category:documentation:admins topics in the admins subcategory of documentation
category:bug,feature topics in the bug or feature category including all subcategories
=category:bug,feature topics in the bug or feature category excluding all subcategories
-category:bug,feature excluding topics in the bug or feature category including all subcategories
-=category:bug,feature excluding topics in the bug or feature category only excluding all subcategories
categories: alias for category

tag:bug+feature topics tagged both bug and feature
tag:bug,feature topics tagged either bug or feature
-tag:bug+feature excluding topics tagged bug and feature
-tag:bug,feature excluding topics tagged bug or feature
tags: alias for tag

created-by:@USERNAME topics created by a specific user

posts-min:X topics with X or more amount of posts
posts-max:X topics with no more than max posts
posters-min:X topics where at least X different users have posted
posters-max:X topics where at most X different users have posted
likes-min:X topics with X or more number of likes
likes-max:X topics with no more than X number of likes
likes-op-min:X topics with first post that has X or more number of likes
likes-op-max:X topics with first post that has no more than X number of likes
views-min:X topics with X or more number of views
views-max:X topics with no more than X number of views

activity-before:YYYY-MM-DD topics with latest bump before specified date
activity-after:YYYY-MM-DD topicslatest bump after specified date
created-before:YYYY-MM-DD created before specified date
created-after:YYYY-MM-DD created after specified date
latest-post-before:YYYY-MM-DD latest post created before specified date
latest-post-after:YYYY-MM-DD latest post created after specified date

order:activity order by bump date desc
order:latest-post order by latest post creation desc
order:created order by topic creation desc
order:views order by topic views desc
order:likes order by number of likes in the topic desc
order:likes-op order by number of likes in the first post of each topic desc
order:posters order by number of people who have posted desc
order:category order by category name
order:ANY-asc flip order on results so it is ascending

Feedback

We would love to find out from the community here if this feature will be valuable for your own community and would also like to know how you’re using it.

If there are any filters that you feel like will help you with your needs, do let us know as with with examples of what you are trying to do.

Finally, we want to highlight that this is a very early version of the feature and it is still considered experimental at this point. The user experience needs improvement and we are currently working on adding some sort of inline autocomplete or even an interface to allow users to build out a topics filtering query language without having to remember all the filters by heart.

30 Likes

What did I miss…?
It doesn’t look like it returns topics that are in the bug category tagged with both chat and #pri-high .

2 Likes

I don’t think you should be able to see the priority tags. They’re just for us. :shushing_face: :slight_smile:

Does it work if you don’t include it?

3 Likes


Looks like if I remove this tag it doesn’t work either


update: the “alias” works perfectly.

2 Likes

Sorry I just realised my PR to add support for the tag: alias was not merged.

It has now been merged so the tag: alias should work soon.

6 Likes

Another problem: tags filter currently don’t support non-ASCII characters, such as Chinese.

Example: tags:一个不存在的标签 returns every topics, but tags:a-non-existent-tag returns nothing, as expected.


I checked the source, it’s caused by

    value.scan(
        /\A(?<tag_names>([a-zA-Z0-9\-]+)(?<delimiter>[,+])?([a-zA-Z0-9\-]+)?(\k<delimiter>[a-zA-Z0-9\-]+)*)\z/,
5 Likes

Kudos for the nice work @tgxworld . This opens up multiple possibilities.

Just curious to know if it could provide a contextual filtering option ?

For eg. If I select announcements category from sidebar, can we show the filter panel (the new one you have created) at the top to filter by multiple tags (chat, new-feature) within the category.

Currently one cannot filter by multiple tags as an end user intuitively - manually we have to use /tags/interesection/chat/new-feature endpoint. End users may not be aware of this possibility especially to do it within a category.

5 Likes

O good catch. I have a fix for tags in

The category filter will need a similar fix but it is slightly more complicated. I should have it completed by next week.

5 Likes

There’s a missing translation string when a new topic appears in /filter:

[en.topic_count_all count=1]

4 Likes

The feature sounds solid and will definitely help building better & customized feeds of topics for our users! Thank you!

Meanwhile I have a question if this feature allows us to approach embedding latest posts from across multiple topics within specific categories/tags?

1 Like

No, that’s not currently part of the plan here, I don’t think.

If you give the current feature a try as is and still find this is something you’d like to be able to do, can you start a new topic about it with a bit more detail about what you’re thinking?

1 Like

Thanks for this very useful feature!

Would it be possible to also add created-by:me or something similar that automatically filters for topics created by the current user? This would of course be similar to /my/activity/topics , but it might be useful for combining with other filters and adding it to the sidebar for all users.

Also, how about a in:participated filter for all topics that I have posted in regardless of their tracking/notification setting?

5 Likes

This is great! :pray: I’d also love to have support for status:unsolved. I also think it would be great if we could construct a filter with something like assigned:me so that the result is different, depending on the user. Use case: a bot that messages our moderators with links they can click to pull up their assigned topics. This would be handy so that we can have a generic message that is sent to all moderators with links to all the queries they need to reference when moderating the forum. Obviously, they can navigate to the assigned topics easily from the web UI, but I think it would be a small QoL improvement if they can click a link or bookmark.

4 Likes

There is some precedence for this kind of thing in the current feature, so I think we can certainly consider other things like this:

3 Likes

Hi,

Can someone let me know if this is in the public version or some sort of beta? Didn’t find the setting.

Hi Tony :wave:

Is your instance up-to-date?

I have the setting on my test forum:

It’s also available on Discourse Hosted forums, not only self-hosted.

As stated it’s “experimental”, which means there might/will be many changes over time, and bugs or inconsistency to expect.

1 Like

I already find this very helpful to explain basic functionality of Discourse to community managers new to the platform. That is: We have a collection of topics and we can filter and sort them in many ways.

So far, these filters have been spread out across the interface, but the filter route offers one central place to access and learn about the available options:

With this in mind, I’d find it helpful to have two more options included:

  • in the Date section, also filter by relative time (last week, month, year,…)
  • in the Sort section, also sort by popularity (which is different to number of likes)
3 Likes

I like the feature. I would like to be able to search just for plain text though. Sometimes I find my self needing to find a deleted topic but dont know what user made it so I need to go through a bunch before I find it instead of juts being able to search through deleted with a key word(s)

I think the aspiration is to wire this up to the Search at some point in the future for parity, though I’m afraid there’s no definitive timeline on that.

3 Likes

Can you sort / order the result by the number of replies or number of votes? I was hoping to use this to list feature requests ordered by community interest, while filtering out those tagged as ‘implemented’. However, it doesn’t seem to be an option.

My use case is described in more detail here.

2 Likes