# Can I exclude usernames from search

**URL:** https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480
**Category:** Feature
**Tags:** search
**Created:** [April 2, 2023, 2:31am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480 "2023-04-02T02:31:44Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![DanFFA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danffa/32/300890_2.png) [@DanFFA](https://meta.discourse.org/u/DanFFA)
#### Post date: [April 2, 2023, 2:31am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/1 "2023-04-02T02:31:44Z")

</div>

Is there a way to remove a specific user’s posts from the search results? Currently, if a highly active user has a username that starts with or otherwise includes a popular term in a community such as…

Search term: ‘ABCD’  
Username: ‘ABCDAndUser…’

…Searching said term often brings up a list of the username’s posts, to the point where it can be near impossible to differentiate results of that user’s random posts from ones that are actually on-topic and simply include that user in the discussion. Ideally, most members would desire a list of on-topic posts over ones that only include said user posting without the term in active use.

Edit: Currently I’m not aware of a workaround for this other than changing said username and/or users blocking said username while conducting their search. Neither of these are ideal.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [April 2, 2023, 5:32am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/2 "2023-04-02T05:32:21Z")

</div>

Oh, wow. Is it actually bringing up posts just made by that person, or is it posts which have replies which literally include their username?

---

<div class="post-metadata">

### Author: ![DanFFA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danffa/32/300890_2.png) [@DanFFA](https://meta.discourse.org/u/DanFFA)
#### Post date: [April 2, 2023, 2:02pm UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/3 "2023-04-02T14:02:16Z")

</div>

Ahh good point. On closer inspection, it’s posts which have replies that literally include their username.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [April 2, 2023, 5:05pm UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/4 "2023-04-02T17:05:00Z")

</div>

It does seem like there must be some possible enhancement there — it doesn’t seem right that a name can “hijack” a search like that, and it seems likely that people might pick usernames related to any given forum’s particular topic.

I don’t know how hard this would be under the hood, but it might be good to surpress usernames unless the `@` is there.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [April 2, 2023, 7:58pm UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/5 "2023-04-02T19:58:08Z")

</div>

This is one of the reasons `reserved usernames` exist.

As standard, Discourse blocks the following:

 ![IMG_8030](https://global.discourse-cdn.com/meta/original/4X/4/c/9/4c91047704c698194507cd08b86de497ccd2af54.jpeg)

Nobody wants a user called `discourse` confusing the discussion.

Communities can update this list to add any terms which are specific to their discussion.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [April 2, 2023, 9:07pm UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/6 "2023-04-02T21:07:13Z")

</div>

I don’t think that’s the best solution for this problem. For example, I can imagine on a car forum someone having a username proclaiming that they own or love some car model. Would you really want ban that possibility — or maintain the list?

Also, once I had to ask a support question of AT&T, and I was unable to use the name “Matthew”. Want to guess why?

---

<div class="post-metadata">

### Author: ![DanFFA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danffa/32/300890_2.png) [@DanFFA](https://meta.discourse.org/u/DanFFA)
#### Post date: [April 3, 2023, 2:03am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/7 "2023-04-03T02:03:29Z")

</div>

Maybe I misunderstand the setting as stated. Would you have to reserve every instance of any potentially problematic word in future usernames and retroactively remove it from community members’ usernames as well?

I know for a fact we have members that use the name ‘testuser’ for instance. I.E this only would work as a solution if we used wildcards to ban usernames en masse, no? That seems like it could easily become overbearing across numerous abbreviations (this particular instance was an ETF ticker in a finance community).

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [April 3, 2023, 2:44pm UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/8 "2023-04-03T14:44:29Z")

</div>

Also as a practical matter, the username restriction does not work well with SSO. With that, if the SSO does not enforce the same restriction and the user unwittingly chooses a “banned” name, Discourse will assign them a random long uuid-like username.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 4, 2023, 4:55am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/10 "2023-04-04T04:55:30Z")

</div>

> [@DanFFA](#):
>
> (this particular instance was an ETF ticker in a finance community).

As a concrete example I am guessing

1. a user called themselves msft\_2000
2. Now every time someone says “What @msft\_2000 says” or “what msft\_2000 says” this shows up in search

I am honestly not sure what the right thing is to do, I would probably approach this in the reverse direction.

- Some special plugin that turns MSFT → “magical msft onebox with extra data”
- Parse search queries for known stock tickers and do a transform on the search query.

It is certainly going to be very complicated and costly. Only simple workaround I can think of is renaming users.

---

<div class="post-metadata">

### Author: ![DanFFA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danffa/32/300890_2.png) [@DanFFA](https://meta.discourse.org/u/DanFFA)
#### Post date: [April 4, 2023, 5:19am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/11 "2023-04-04T05:19:22Z")

</div>

Is there a specific reason Discourse doesn’t mimic the Google minus sign to exclude search results containing a term (or in this case a username as a term to exclude) from a search? I think that would have been the simplest workaround if it existed.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 4, 2023, 5:23am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/12 "2023-04-04T05:23:53Z")

</div>

Sorry, I need this conversation grounded.

You are saying you would like to search for:

`msft -msft_user`

This is technically possible in our current index, but would require a bunch of work to get it going. Especially since `msft_user` gets tokenized down to two tokens (msft / user) so we would need to use the `is followed by` syntax. I can see the merit of implementing a `-` operator but it is not a trivial change.

---

<div class="post-metadata">

### Author: ![DanFFA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danffa/32/300890_2.png) [@DanFFA](https://meta.discourse.org/u/DanFFA)
#### Post date: [April 4, 2023, 5:30am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/13 "2023-04-04T05:30:55Z")

</div>

Yes, apologies if this got too long in the tooth. That was certainly not my intention.

I figured I would ask after one of our members brought up this situation, since it seemed like a fitting change when your team was just recently working on improvements to the search.

This answers the query. 👍

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 4, 2023, 5:59am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/14 "2023-04-04T05:59:57Z")

</div>

No problems at all, I think it is a perfectly legitimate request, supporting `-something` and `-"some longer phrase"` could be quite useful in all sorts of cases.

It is not a trivial change, but also it is not an enormous piece of work, the main thing about this change is that it is a bit fiddly.

I am tagging this and next round of work on search we can revisit!

Thanks heaps for raising this.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [April 4, 2023, 11:07am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/15 "2023-04-04T11:07:21Z")

</div>

Isn’t this also just a good use case for tags?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 5, 2023, 12:52am UTC](https://meta.discourse.org/t/can-i-exclude-usernames-from-search/260480/16 "2023-04-05T00:52:01Z")

</div>

excluding tags is supported though:

`-tags:bug+feature`: excluding topics tagged bug and feature  
`-tags:bug,feature`: excluding topics tagged bug or feature
