How to search/filter untagged topics

I’m looking to use the search API to find all tags that match a string but have no tags. Is this possible? My hope is that this would work similar to in:solved (How to search and filter solved/unsolved topics?).

More generally, is there a list of all such search terms? (Happy to look at code if someone could provide a pointer.)

Alternatively, I could use a filter more like Filter topics by tag in common with "top", "read", "bookmarks" and "posted" filters but it’s unclear how that works together with the search API.

Thanks.
~Josh

1 Like

For reference here the search.rb file
https://github.com/discourse/discourse/blob/master/lib/search.rb

however you can easily find topics without tags using the data explorer plugin or you can even search topics without a specific tag using the not operator, New search operator "not" for tags only

3 Likes

Thanks! The advanced filters starting around line 269 are very useful:

  advanced_filter(/^status:open$/) do |posts|
  advanced_filter(/^status:closed$/) do |posts|
  advanced_filter(/^status:archived$/) do |posts|
  advanced_filter(/^status:noreplies$/) do |posts|
  advanced_filter(/^status:single_user$/) do |posts|
  advanced_filter(/^in:first|^f$/) do |posts|
  advanced_filter(/^in:pinned$/) do |posts|
  advanced_filter(/^in:unpinned$/) do |posts|
  advanced_filter(/^in:(likes|bookmarks)$/) do |posts, match|
  advanced_filter(/^in:posted$/) do |posts|
  advanced_filter(/^in:seen$/) do |posts|
  advanced_filter(/^in:unseen$/) do |posts|
  advanced_filter(/^in:wiki$/) do |posts, match|
  advanced_filter(/^posts_count:(\d+)$/) do |posts, match|
  advanced_filter(/^min_post_count:(\d+)$/) do |posts, match|
  advanced_filter(/^badge:(.*)$/) do |posts, match|
  advanced_filter(/^with:images$/) do |posts|
  advanced_filter(/^\#([\p{L}0-9\-:=]+)$/) do |posts, match|
  advanced_filter(/^group:(.+)$/) do |posts, match|
  advanced_filter(/^user:(.+)$/) do |posts, match|
  advanced_filter(/^\@([a-zA-Z0-9_\-.]+)$/) do |posts, match|
  advanced_filter(/^before:(.*)$/) do |posts, match|
  advanced_filter(/^after:(.*)$/) do |posts, match|
  advanced_filter(/^tags?:([\p{L}0-9,\-_+]+)$/) do |posts, match|
  advanced_filter(/^\-tags?:([\p{L}0-9,\-_+]+)$/) do |posts, match|
  advanced_filter(/^filetypes?:([a-zA-Z0-9,\-_]+)$/) do |posts, match|

I assume “solved”/“unsolved” would show up in the plugin code, eh?

Interesting. Thanks. We’re currently looking for an API solution for auto-generating a list of all topics that we need to respond to.

Yup, that’s where I started and ended up wanting more :smile: Very useful.

Is there a technical reason (performance of the query, etc.) that an in:untagged advanced filter wouldn’t work?

~J.

Not of which I am aware, but our engineers should answer this question. I believe there were no requests to implement this kind of search.

Tested locally via d/boot_env --init:

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

2 Likes