# User mention search should prioritize users with access to the current category

**URL:** https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319
**Category:** UX
**Created:** [5월 10, 2019, 12:08오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319 "2019-05-10T00:08:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [5월 10, 2019, 12:08오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/1 "2019-05-10T00:08:00Z")

</div>

If I’m writing a post in a category where only some users have access, the mention search (`@username`) should list users with access to the category first.

I would go as far that it should prioritize more active members too, when a full match happens anywhere.

Eg:

Typing `@arpit` and none of the options contain @techAPJ, while showing users that doesn’t visit in years, have zero posts, etc.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 10, 2019, 12:10오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/2 "2019-05-10T00:10:53Z")

</div>

> [@Falco](#):
>
> Typing `@arpit` and none of the options contain @techAPJ, while showing users that doesn’t visit in years, have zero posts, etc.

This is a deeper problem since that list should be ordered by total post count, I would think @sam .. did we regress here?

As I recall the sort order was

- prioritize people _in the current topic_

and that is good and proper.. but after that it should be

- prioritize _most frequent posters_ (globally)

I don’t think it needs to be so sophisticated as to factor in specific categories and permissions etc.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 10, 2019, 12:14오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/3 "2019-05-10T00:14:00Z")

</div>

I suspect this might also be a bug based on matching on “real name” versus “username” @Falco

---

<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: [5월 10, 2019, 2:15오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/4 "2019-05-10T02:15:11Z")

</div>

> [@codinghorror](#):
>
> prioritize _most frequent posters_ (globally)

Is there any time window on this? I would hate to see a prolific poster who leaves a community permanently dominate a search.

---

<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: [5월 10, 2019, 2:17오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/5 "2019-05-10T02:17:12Z")

</div>

The current priority is

1. exact match
2. in the topic
3. order by last seen

Most frequent poster was never done.

I do agree with the OP though it would be nice if #3 here was “in list of groups that have access to this topic”

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 10, 2019, 4:27오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/6 "2019-05-10T04:27:19Z")

</div>

I don’t think this is right.. so you’re saying in this list..

 ![image](https://global.discourse-cdn.com/meta/original/3X/f/3/f3c1e1385fafa86c69d0261f4e2894277700a9da.png)

all those “arpits” were “last seen” before _our_ Arpit? I don’t think so, my friend.. that does not even pass the 👃 test.

I’m pretty sure it’s what I said it was

> [@codinghorror](#):
>
> a bug based on matching on “real name” versus “username”

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 10, 2019, 4:29오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/7 "2019-05-10T04:29:21Z")

</div>

Maybe the expectation that you can type real name and get decent results is just an unrealistic one? You have to at least match part of the **username** for this to work, e.g. `techapj` versus `arpit`

---

<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: [5월 10, 2019, 4:34오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/8 "2019-05-10T04:34:17Z")

</div>

The scoping is done with this order if the site setting 'enable\_name?` is enabled like it is here:

`order(DB.sql_fragment("CASE WHEN username_lower LIKE ? THEN 0 ELSE 1 END ASC", @term_like))`

So we get:

`ORDER BY CASE WHEN username_lower LIKE 'arpit%' THEN 0 ELSE 1 END ASC, last_seen_at DESC LIMIT 19`

This means username matches are unconditionally first.

We could change this I guess, but I worry that this will lead to a reverse problem.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 10, 2019, 4:42오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/9 "2019-05-10T04:42:17Z")

</div>

I dunno @falco I have very mixed feelings about this.. you’re basically saying that real name matches should have high priority. Is there any reason you couldn’t remember it was `techapj` and not `arpit`?

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [5월 10, 2019, 5:28오전 UTC](https://meta.discourse.org/t/user-mention-search-should-prioritize-users-with-access-to-the-current-category/117319/10 "2019-05-10T05:28:46Z")

</div>

I don’t know about Falco and techarp but I often have to resort to real names because, well, some usernames are just not that easy to remember…
