106

Here's my problem: I know I've posted something on Stack Overflow about a particular topic. I know how to search all my answers with a given keyword, and that feature works well. But, if I don't find anything, I assume that it must have been a comment that I posted on the subject, and I'd like to be able to find it, and the question it belongs to.

I have read:

this question, this question, and this question on Meta.

Basically, all the responses to those are about 3 years old, so it seems reasonable (to me) to ask this again ...

I've also tried just searching on Google with the keyword(s), my SO username (which I guess unfortunately is (a) not that unusual, and (b) a substring of other words, like unfortunately!), and site:stackoverflow.com, without much success.

Is there a Stack Exchange API or query that I could run to search my comments, using a keyword or keywords?

I did see one response by Jeff Atwood in one of the questions linked to above indicating that the (2009) inability to do this was annoying him, too, so hopefully I'm not the only one who's tried to do this.

4
  • 1
    +1 @Nate I didn't see yours when I posted mine. But I also asked for some limited retag/folder features in my question.
    – bonCodigo
    Commented Jan 7, 2013 at 14:15
  • See if the answer here helps.
    – yorkw
    Commented Jul 19, 2013 at 1:59
  • @yorkw, yes, it definitely does! Although I'd love it to be built into the stack exchange web application itself, your query seems to do what I wanted. If you'd like to post your answer again here, I will accept it as a solution. Thanks.
    – Nate
    Commented Jul 19, 2013 at 5:33
  • Related, but asking if there's an existing on-site page that provides this functionality: Finding my own comments on questions and answers
    – starball
    Commented Dec 29, 2022 at 5:21

2 Answers 2

73

I have created a data explorer query to search a post by comment texts and userId:

SELECT Id AS [Comment Link], Score, Text 
  FROM Comments 
 WHERE UPPER(Text) LIKE UPPER('%##CommentText##%')
   AND UserId = '##UserId##'
 ORDER BY Score DESC

I have also created a query to search for multiple keywords:

You can edit the query to customize it for your use.

11
  • 10
    Just a heads-up that, for example, if you want to search stackoverflow.com for comments, using a stack overflow user Id, you would replace meta.stackoverflow in your data explorer query URL with just stackoverflow.
    – Nate
    Commented Apr 24, 2014 at 6:16
  • Yup @Nate. You have to switch the site you want to search in. I have provided the link for Meta.SO.
    – Himanshu
    Commented Apr 24, 2014 at 6:22
  • is there anyway that I can filter responses I got from a user?
    – Honey
    Commented Apr 16, 2017 at 23:06
  • 3
    For anyone using these queries to search Russian: you'll need to use N-strings in LIKE-patterns, as done here: data.stackexchange.com/ru/revision/775629/960188/…
    – D-side
    Commented Dec 28, 2017 at 15:47
  • Do you know how to sort by descending date?
    – Noitidart
    Commented May 3, 2018 at 22:02
  • 2
    @Noitidart : Here you go...
    – Himanshu
    Commented May 4, 2018 at 5:28
  • For complete SQL newbies like me, you need to remove the #s from the search terms and your user id. :D
    – tjebo
    Commented Jun 23, 2020 at 9:05
  • Can you please explain the [Comment Link] query part, what is that syntax ([...]) meaning? Is it possible to somehow add the thread question title to this query results? Commented Nov 10, 2020 at 21:59
  • 1
    Managed to do it via SELECT Id AS [Comment Link], PostId AS [Post Link], ... yet still don't understand where that AS [Comment Link] and AS [Post Link] are come from or where they are documented. Many thanks for this excellent query, BTW. Commented Nov 10, 2020 at 22:13
  • 3
    @IvanShatsky: Those are Magic Columns specially designed for SEDE. There are few more.
    – Himanshu
    Commented Nov 11, 2020 at 4:01
  • 1
    In a recent question it is recommended both in the accepted answer and in some comments to use COLLATE rather than UPPER(Text) LIKE UPPER('%##CommentText##%'). (It seems that this might be a problem mainly on bigger sites where the Comments table is large.)
    – Martin
    Commented Sep 12, 2023 at 4:08
23
+50

I am adding this answer based on the discussion I had after posting a very similar question. It's truly a great feature if we can have it. I proposed the feature based on Stack Overflow inbox and comments tab.

Each time we want to find some interesting questions/answers that we encountered/interacted, currently there is only one way. Which is very tedious.

  1. Go one by one each page of the comments
  2. Go one by one each page of inbox
  3. Go one by one for each vote...

It can consume lots of time obviously.

So along the most basic keyword search on comments/responses/inbox I suggest having following bonuses as well:-

  • Let user categorize them with their own tags (limited number of tags allowed for user based on reps)

  • Add into folders (with limited numbers of folders allowed per user based on reps) like in Google inbox ...

0

You must log in to answer this question.

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