9

Say Tag 1 has been added as a synonym of Tag 2, so that new questions attempting to use Tag 1 will be automatically pointed to Tag 2. However, the two tags haven't been merged (yet). Then, if you click on Tag 1 or attempt to search for it, you'll automatically be redirected to the tag page for Tag 2.

As stated in the FAQ on tag synonyms and merged tags:

All good tag synonyms should eventually be merged (source). This retags all non-deleted questions tagged with another tag – which is not automatically done when a synonym is created. As merging is not (easily) reversible, it should be done with caution. Only moderators can perform a merge.

However, it can sometimes be tricky to evaluate whether a pair of tags should be merged. Part of that process usually involves seeing how the tags are currently being used, e.g. if they're being used to refer to the same thing. If both tags are only on a few questions each, you can do this pretty easily by just scrolling through the page for Tag 2. However, if Tag 1 is on a lot of questions and Tag 2 is only on a few questions (or vice versa), this isn't quite as feasible – you might have to go through dozens of pages to even find a single question with the less popular tag.

There doesn't seem to be an obvious way on sites to find questions listed separately for the main tag vs. its synonyms. As such, I was wondering if it's possible to use SEDE to find this information.

How can I get a list of questions with an existing tag that's been synonymized (but not merged) into another tag? (SEDE seems like a possible way to get this information, but I'm open to other solutions as well.)

3
  • 1
    Maybe I misunderstood what you mean - but doesn't this simply mean listing the question with the given tag? For example on this site, the tag (careers-germany) seems to be a synonym without merging into the master tag - and I can find those questions using this query or this query.
    – Martin
    Commented Dec 16, 2022 at 20:59
  • 1
    Tangentially, it is not exactly true that searching for a synonym is the same as searching for the master tag - see this bug report. (But I am not sure how exactly the searches for the synonyms work - why some questions are returned when searching for the master tag and some questions when searching for the synonym.)
    – Martin
    Commented Dec 17, 2022 at 5:28
  • 1
    @Martin At least when I recently tested it, once the synonym was created, the questions with the original tag, both deleted and non-deleted, were not returned as results when searching for either the synonym-target tag or the original tag. If the synonym was removed, then all such questions immediately showed as results when searching for the original tag. While the synonym existed, if the synonym-target tag was added to a question, then it showed in results when searching for the synonym-target tag. If there were already questions with the synonym-target, then they showed as results.
    – Makyen
    Commented Dec 17, 2022 at 12:03

1 Answer 1

8

As far as I can tell, SEDE indeed can help with this - all you need is to find the questions with the specific tag. If the question still has the original tag, from SEDE you get the question with this tag- not with the master tag. (In the other words, SEDE keeps the same tags as displayed on questions - so if the tags weren't merged, the synonym and the master tag still retain their questions.)

So all you need is:

SELECT q.Id as [Post Link], 
  q.Tags, q.CreationDate, q.LastActivityDate
FROM Posts q INNER JOIN PostTags pt ON q.Id=pt.PostId
INNER JOIN Tags t ON t.id = pt.TagId
WHERE t.TagName=##tagName##
ORDER BY q.CreationDate DESC

Naturally, you can add further information about the questions and change the ordering in whichever way you please.

Using the PostTags table should be faster than just comparing q.Tags LIKE '%<##Tagname##>%'. (Although it is worth pointing out that the table PostTags doesn't contain information about deleted questions - so if you are interested in those, you can't rely on this table. At least this is how it works on publicly available instance of SEDE - as mentioned in the comments, the devs have access to more data about deleted questions.)


Let us take as an example. It is a synonym with the master tag . At the moment, I get from SEDE 7 questions tagged careers-germany and 2172 questions tagged legacy-stack-overflow-jobs. (Probably it is worth checking after the next update of SEDE - there is a small difference between the numbers from SEDE and the numbers I see on the site.)

The 7 questions tagged , have the tag legacy-stack-overflow-jobs, too. So the query that looks for questions with the synonym but not with the master tag returns no questions in this case.

Interestingly, when I go to see how many questions tagged are on the site, I get 2181 questions when viewing the active tab and 2172 questions when viewing the newest tab.

Similarly, searching for [legacy-stack-overflow-jobs] is:q returns only 2172 questions.


Maybe some smaller example would be easier to work with - let us try and . Using the same query, I get 12 questions tagged canonical-questions and 22 questions tagged canonical. In this case, there is a single question with both tags and 11 question tagged but not .

Searching for [canonical] is:q returns 22 questions. (This is consistent with the behavior described in Makyen's comment - search only returns the question with the master tag, not with the synonym. Perhaps this could be considered a bug - as previously reported here.)

The tag shows 34 questions on the active tab and 22 questions on the newest tab.

Actually, I think that this is a manifestation of another bug - the page with the active tab says "34 questions" but this is small enough to count manually - I only see 33. (So the one question with both tags is probably counted twice. Here is a small SEDE query showing the questions with one of these tags ordered in the same way as in the active tab.)

3
  • 1
    The OP can run the query on the internal SEDE instance as well, which does have deleted posts, when/if that is needed.
    – rene
    Commented Dec 17, 2022 at 12:49
  • 1
    Thank you for the information! I am still learning all the nuances of SEDE :)
    – V2Blast
    Commented Dec 19, 2022 at 18:09
  • 1
    Thanks! This greatly sped up a query (and made it more accurate, because I didn't know about the angle-bracket thing, even) I was writing for a meta.SO question. Commented Jun 30, 2023 at 12:21

You must log in to answer this question.

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