How can I find all Hashtags ever used in Channel?

we have some problems regarding Hashtags…we can’t remember the Hashtagname. Is there a way to find all existing used Hashtags of a channel?

Hi Zugang and welcome to the Mattermost forums!

If you’re using PostgreSQL, the following query could help:

select DISTINCT(regexp_matches(message, '#[^[:space:]#]+', 'g')) from posts where channelid='<your-channel-id>';

The result will look like this:


I have mySQL database…can you provide me also the query for mysql?
And is there a way to find the hashtags for all users (non administrator)

The query shows the hashtags for all users but was limited to a specific channel.
There’s no regexp_matches for MySQL as far as I can see, at least I haven’t found an easy way to port it, but this linux command should be good enough and it also sorts the hashtags by number of occurences.

# echo "SELECT Message FROM Posts;" | mysql -N mm720 | grep -Po '\K#[^[:space:]#]+' | sort | uniq -c
      2 #hash2
      1 #hash3
      1 #hash4
      1 #hashtag
      1 #hashtag1

This command will search for hashtags in all posts in all channels on the local mysql server which you can connect to using no password to the database mm720.
If you require a specific username and password, you will have to add the -u and -p parameters to the mysql command accordingly. Let me know what your setup looks like if you need help with that.

Thanks a lot! This worked for me!
I also created now a HashTag named #HashTags, then all users can find all currently used HashTags.
→ Maybe there will be in Future an search engine which can find all used hashtags?
Because double use and type errors are often happen…

OK so you posted all currently available hashtags under the hashtag #Hashtags now so people can find it? :slight_smile:

With regards to the search for Hashtags: Maybe there is one, let me see what I can find out and otherwise I’ll see if the channels team is already aware of such a feature.

yes, our posts look now like
#myTopic #Hashtags…when we create a new Hashtag…we are not a lot of members, therefore it is possible,but it isnt a smart solution…This feature in future would be great!