5

I would like to exclude any other tag, and not just some specified tags.

QUESTION:

I would like to search for:

[reactjs] or [javascript] exclusively and not include [any other tag] even if they appear combined with [react] or [javascript]

So I would get questions tagged:

  • [reactjs] only (single tag)

  • [javascript] only (single tag)

  • [react] and [javascript] only (just these two tags)

  • nothing else

Or maybe:

[reactjs] and [javascript] and exclude everything else.

6
  • 3
    I don't know of a way to do this. But please feed my curiosity as to why you want this? Especially when taking into account that questions tend to be excessively over-tagged.
    – Gimby
    Commented Apr 18, 2019 at 10:54
  • Take my example: I'm not a very experienced developer. But I've been studying React for a while now. I would like to filter some question that are related to [react] itself. But if your question has an issue that mixes react with some [meteor] api, for example, I'm probably not going to be able to help, but if your question is basically about [react] and your looking to clarify something about a React feature, you are probably going to tag it with [react] only and I would like to find that and help out. Commented Apr 18, 2019 at 11:00
  • 3
    Yes, but the solution you're marrying yourself to will exclude any question which has any extra tag, even if that tag is completely superfluous like 'httpclient' or something. It is better to setup a list of ignored tags instead, you may need to define a couple dozen but eventually the topics you really have no interest in will disappear. From the homepage at least, I'm not really sure how it affects the site search (but who uses the site search anyway)
    – Gimby
    Commented Apr 18, 2019 at 11:10
  • Sure. I don't think this is the most used search technique, but it might be handy sometimes. The tag list that could come together with the one I'm interested in is huge. Impractical to exclude them all. I think it's a "nice to have" feature. Thanks! Commented Apr 18, 2019 at 11:50
  • I don't think this is possible. A similar question has a comment that points to a SEDE query you may find useful: meta.stackoverflow.com/questions/267173/…
    – BSMP
    Commented Apr 18, 2019 at 12:43
  • For a single tag you can use this answer from MSE. I couldn't figure out how to get it to work for two tags.
    – Wai Ha Lee
    Commented Apr 18, 2019 at 12:53

1 Answer 1

6

You only achieve that by means of SEDE. This query (that was forked from my answer here) does that:

-- will hold our selected tags
create table #selectedtags( id int primary key
                          , value nvarchar(35) collate SQL_Latin1_General_CP1_CS_AS)

-- fill selectedtags based on the ; delimited tags 
insert into
#selectedtags
select t.id, rtrim(ltrim(value))
from string_split(##tags:string?winforms;linq##, ';') v
inner join tags t on t.tagname = rtrim(ltrim(value))

select top 1000 id as [Post Link]
     , creationdate
     , score
     , tags
from
(
select p.id 
     , p.creationdate
     , p.score
     , p.tags
from posts p
inner join posttags pt 
        on pt.postid = p.id  -- for each tag per post a row 
inner join #selectedtags st 
        on st.id = pt.tagid -- select the tags
-- check if the post doesn't have more tags
where closeddate is not null
and 
( select count(*) 
  from posttags pc 
  where pc.postid = p.id) = 1

union 
-- select posts
select p.id 
     , p.creationdate
     , p.score
     , p.tags
from posts p
inner join posttags pt 
        on pt.postid = p.id  -- for each tag per post a row 
inner join #selectedtags st 
        on st.id = pt.tagid -- select the tags
-- check if the post doesn't have more tags
where closeddate is not null
and (select count(*) 
     from posttags pc 
     where pc.postid = p.id) = (select count(*) 
                   from #selectedtags)
-- have the exact count of tags                                 
group by p.id 
     , p.creationdate
     , p.score
     , p.tags
having count(*) = (select count(*) 
                   from #selectedtags)
) data
order by  creationdate desc

When run today, this is what your result will look like:

javascript and reactjs questions

Keep in mind SEDE is only updated once a week, on Sunday. Say Hi in chat and checkout the tutorial

You must log in to answer this question.

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