لدي فئة تحتوي على العديد من المواضيع (أكثر من 900)، وجميعها تحمل نفس الوسم، لنقل answered، والذي نستخدمه لتتبع المنشورات التي تم الرد عليها.
كثير منها يحتوي أيضًا على وسوم أخرى: deployment, cli, api، وما إلى ذلك، لتحديد “موضوع” السؤال.
كيف يمكنني العثور على جميع المواضيع في فئتي التي تحتوي فقط على وسم 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.
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.
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