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

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 .