Фильтр списка тем

Мы недавно внедрили инновационный маршрут /filter, позволяющий более гибко фильтровать список тем. Важно отметить, что это первый шаг к созданию единого языка фильтрации тем для поиска и фильтрации. Кроме того, выделенный маршрут для фильтрации списка тем повышает настраиваемость боковой панели: теперь пользователи могут добавлять ссылки как пользовательские ссылки разделов в боковую панель.

Как это работает

На странице /filter есть поле ввода, куда пользователи могут ввести строку запроса для фильтрации списка тем.

Например, category:documentation tag:how-to+email отфильтрует темы, находящиеся в категории Documentation и помеченные тегами how-to и email одновременно.

В настоящее время поддерживается следующий список фильтров:

status:open — темы, которые не закрыты и не заархивированы
status:closed — закрытые темы
status:public — темы, не имеющие ограничений на чтение (например, принадлежащие защищённой категории)
status:archived — заархивированные темы
status:unlisted — невидимые темы
status:listed — видимые темы
status:deleted — удалённые темы

in:pinned — закреплённые темы (глобальные или в рамках категории)
in:watching — темы, за которыми я слежу; поддерживает значения (muted, normal, tracking, watching_first_post): позволяет отфильтровать темы, за которыми вы следите, наблюдаете и т. д. — несколько значений можно разделять запятыми
in:bookmarked — темы, которые я добавил в закладки

category:bug — темы в категории bug и во всех её подкатегориях
=category:bug — темы в категории bug, исключая подкатегории
category:documentation:admins — темы в подкатегории admins категории documentation
category:bug,feature — темы в категориях bug или feature, включая все подкатегории
=category:bug,feature — темы в категориях bug или feature, исключая все подкатегории
-category:bug,feature — исключение тем в категориях bug или feature, включая все подкатегории
-=category:bug,feature — исключение тем в категориях bug или feature, исключая все подкатегории
categories: — синоним для category

tag:bug+feature — темы с тегами bug и feature одновременно
tag:bug,feature — темы с тегами bug или feature
-tag:bug+feature — исключение тем с тегами bug и feature
-tag:bug,feature — исключение тем с тегами bug или feature
tags: — синоним для tag

tag_group:tag_group_name — темы с любыми тегами из группы tag_group
-tag_group:tag_group_name — исключение тем с любыми тегами из группы tag_group

created-by:@USERNAME — темы, созданные конкретным пользователем

posts-min:X — темы с X или более сообщениями
posts-max:X — темы с не более чем X сообщениями
posters-min:X — темы, где опубликовали сообщения как минимум X разных пользователей
posters-max:X — темы, где опубликовали сообщения не более чем X разных пользователей
likes-min:X — темы с X или более лайками
likes-max:X — темы с не более чем X лайками
likes-op-min:X — темы, у которых первое сообщение имеет X или более лайков
likes-op-max:X — темы, у которых первое сообщение имеет не более X лайков
views-min:X — темы с X или более просмотрами
views-max:X — темы с не более чем X просмотрами

activity-before:YYYY-MM-DD — темы с последним обновлением до указанной даты
activity-after:YYYY-MM-DD — темы с последним обновлением после указанной даты
created-before:YYYY-MM-DD — созданные до указанной даты
created-after:YYYY-MM-DD — созданные после указанной даты
latest-post-before:YYYY-MM-DD — темы с последним сообщением, созданным до указанной даты
latest-post-after:YYYY-MM-DD — темы с последним сообщением, созданным после указанной даты

order:activity — сортировка по дате последнего обновления (по убыванию)
order:latest-post — сортировка по дате создания последнего сообщения (по убыванию)
order:created — сортировка по дате создания темы (по убыванию)
order:views — сортировка по количеству просмотров (по убыванию)
order:likes — сортировка по количеству лайков в теме (по убыванию)
order:likes-op — сортировка по количеству лайков в первом сообщении каждой темы (по убыванию)
order:posters — сортировка по количеству участников, публиковавших сообщения (по убыванию)
order:category — сортировка по названию категории
order:ANY-asc — изменение порядка результатов на восходящий

Обратная связь

Мы хотели бы узнать у сообщества, насколько эта функция будет полезна для ваших собственных сообществ, а также как вы её используете.

Если вы считаете, что какие-то фильтры помогут вам в решении ваших задач, пожалуйста, сообщите нам об этом, приведя примеры того, что вы пытаетесь сделать.

Наконец, хотим подчеркнуть, что это очень ранняя версия функции, и на данный момент она считается экспериментальной. Пользовательский интерфейс требует доработки, и мы сейчас работаем над добавлением автодополнения прямо в строке ввода или даже интерфейса, который позволит пользователям формировать запросы для фильтрации тем, не запоминая все фильтры наизусть.

33 лайка
Filter topics without a specific tag
Is there a way to export topics/posts that are displayed when filtering?
Building an Index from topics
Discourse Custom Topic Lists
How to show topics ordered by date of publishing via user interface?
How to show topics ordered by date of publishing via user interface?
How to exclude a Category from search or Search through all categories except one+
Filter to eliminate from view: broken plug-ins/theme Components
How can I filter/paginate the list CategoryTopics route?
URL syntax to filter on multiple tags within a category
Why Filter doesn't show me options like the shown on Meta?
My topics not in latest?
How to show topics ordered by date of publishing via user interface?
Wp-discourse-shortcodes plugin
Latest/Hot/Top - what about Best/Popular? Request for automatic selection
Using query strings to filter topic views
Streamline Tag Intersections
Adding Following to the /filter option
Filtering topic lists in Discourse
Filter topics with certain categories OR certain tags
Using query strings to filter topic views
How are you increasing response rate in a community support forum?
Topic filter UI isn't very intuitive
Searching for content effectively
Filtered Topic Lists
Topic list parameter for created after
Using query strings to filter topic views
Disappearing bookmarks and expected behavior of /bookmarks
How to show topic-map on non-commented posts?
View that contains topics of specific categories?
Filter posts with a specific tag on latest
Allow searching across multiple categories
Combined Watching/Tracking list
Put every closed topic at the bottom of a category
Sort display of topics Alphabetically

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 лайка

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 лайка


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


update: the “alias” works perfectly.

2 лайка

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 лайков

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 лайков

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 лайков

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 лайков

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

[en.topic_count_all count=1]

4 лайка

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 лайк

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 лайк

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 лайков

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 лайка

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 лайка

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 лайк

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)
5 лайков

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 лайка

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 лайка