6

Given that the limit on the number of tags is five, there is a possibility that a question that uses all five tags may not be using the best choice of tags for others to locate that question at a later date.

There is no option in search to identify such questions. For example, tagcount:5 is not available.

Is there another way to identify questions with exactly five tags, which could be used along with other search options. Similar to [tag1] -[tag2] tagcount:5.

This question is not the same as: How can I limit search results by the number of tags?, which would select one tag while excluding all others. In my case, I want to select all questions with five tags, then apply the tag search to identify questions that both include and exclude particular tags without regard to the other tag names.

5
  • 4
    Write a SEDE query Commented Aug 28, 2021 at 20:05
  • 6
    Here is a sede query: data.stackexchange.com/stackoverflow/query/1453848
    – rene Mod
    Commented Aug 28, 2021 at 20:07
  • @rene Why > 4 instead of = 5? It actually returns questions with six tags: data.stackexchange.com/stackoverflow/revision/1453885/1784789
    – 41686d6564
    Commented Aug 28, 2021 at 23:48
  • @41686d6564 I assumed the OP was interested in cases where all tag slots were occupied. Having 6 or 7 tags on a question is a fluke but the effect is the same: no more tags can be added by regular means. That is why I opted for > 4. In my answer I used the = given the fact that the alternative disturbed you so much.
    – rene Mod
    Commented Aug 29, 2021 at 5:56
  • @rene Haha! It didn't really disturb me I was just curious why you chose > 4 because I thought no posts have more than 5 anyway. Then, I found out I was wrong :)
    – 41686d6564
    Commented Aug 29, 2021 at 9:05

1 Answer 1

9

You can't with the search capabilities as found on the site. But you can with the Stack Exchange Data Explorer.

Here is an example query that implements the search criteria you asked for.

;with postwithtagcount as 
(
  select pt.postid 
  from posttags pt
  group by postid
  having count(*)  = ##tagcount##
),
includetags as (
  select distinct
         pt.postid
  from posttags pt
  inner join postwithtagcount pwt on pwt.postid = pt.postid
  inner join tags t on pt.tagid = t.id
  where t.tagname like ##includetag:string##
),
excludetags as (
  select distinct
         pt.postid
  from posttags pt
  inner join postwithtagcount pwt on pwt.postid = pt.postid
  inner join tags t on pt.tagid = t.id
  where t.tagname like ##excludetag:string##
)
 
select top 1000 p.id [Post Link]
     , score
     , creationdate
     , closeddate
     , lastactivitydate
     , answercount
from posts p 
inner join includetags it on it.postid = p.id
left outer join excludetags et on et.postid = p.id
where et.postid is null
order by p.id desc

When run today (with the refresh of the Stack Overflow database into SEDE still going) this is the result for question with 5 tags and c# not tagged winforms:

showing query result with columns link, score, creationdate, closeddate, lastactivitydate, answercount

Keep in mind SEDE is updated once a week, starting at Sunday 03:00 UTC.

I invite you and others to try out the tutorial written by the unforgettable Monica Cellio.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .