検索でのワイルドカードタグ:特定のタグを持たないトピックの検索は可能か?

以下のような状況です:

1 つのカテゴリに多数のトピック(900 件以上)があり、それらすべてに同じタグ(例:answered)が付いています。これは、返信された投稿を追跡するために使用しています。

また、多くのトピックには「質問のテーマ」を示すために、deploymentcliapi などの他のタグも付いています。

このカテゴリ内で、answered タグのみが付いていて、他のタグが一切付いていないトピックをすべて見つけるにはどうすればよいでしょうか?

例えば tags:answered -tags:redirects という構文で検索すると、answered タグは付いているが redirects タグが付いていないものがすべて取得できることを確認しました。

しかし、この方法を自分の状況に適用しようとすると、除外したいタグをすべて個別にリストアップする必要があり、タグの数も多いため現実的ではありません。

タグ検索でワイルドカードを使用することは可能でしょうか?例えば tags:answered -tags: * のような構文です。

もし不可能であれば、answered タグのみが付いていて他のタグが一切付いていないもののリストを取得する別の方法はありますか?

ご意見をお聞かせください。

This is the only way I can see of excluding tags from a search.

It is possible to search for tag groups by using the category modifier with the tag group’s slug. For example, if you had a tag group called ‘topic status’, you can search for its tags with #topic-status, but tags can’t be excluded in this way, so -#topic-status doesn’t work.

「いいね!」 1

Thanks @simon - I think I’ll try adding all the tags I don’t want to search for to a tag group as suggested, and try that :muscle:

Sorry, I wasn’t as clear as I could have been. If it was possible to exclude a tag group from search, this approach would work, but I can’t see any way to exclude a tag group from search results.

「いいね!」 2

oh, i misunderstood. So its not possible - at all?

You could get a list of topics that only have a single given tag with a Data Explorer query. Something like this might work for you:

--[params]
-- string :tag_name

with tagged_topics AS (
SELECT 
topic_id
FROM topic_tags
JOIN tags
ON tags.id = topic_tags.tag_id
WHERE tags.name = :tag_name
),
counts AS (
SELECT
COUNT(id) AS tag_count,
tagged_topics.topic_id
FROM topic_tags
JOIN tagged_topics
ON tagged_topics.topic_id = topic_tags.topic_id
GROUP BY tagged_topics.topic_id
)

SELECT
c.topic_id
FROM counts c
JOIN topics t
ON t.id = c.topic_id
WHERE t.deleted_at IS NULL
AND t.archetype = 'regular'
AND c.tag_count = 1
「いいね!」 1