Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Local users don't always appear first even with prefer_local_users: true #15521

Open
gabrc52 opened this issue May 2, 2023 · 1 comment
Open
Labels
A-User-Directory T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@gabrc52
Copy link
Contributor

gabrc52 commented May 2, 2023

Description

This might be somewhere between bug and feature request, since the description of the configuration setting says it prefers them but does not put them first. Depending on the use case (i.e. schools and other organizations), it is ideal to show the local users first and foremost.

prefer_local_users: Defines whether to prefer local users in search query results. If set to true, local users are more likely to appear above remote users when searching the user directory. Defaults to false.

Steps to reproduce

  1. In homeserver.yaml config, set prefer_local_users: true
  2. Search for a user by localpart using /user_directory/search
  3. Notice that results from my homeserver (matrix.mit.edu) appears in fourth place whereas I expected it to be above the other remove homeservers.

Homeserver

matrix.mit.edu

Synapse Version

1.81.0+jammy1

Installation Method

Debian packages from packages.matrix.org

Database

Single PostgreSQL 14+238 server, no ports or restores

Workers

Single process

Platform

Ubuntu 20.04

Configuration

user_directory:
  enabled: true
  search_all_users: true
  prefer_local_users: true

Relevant log output

{@rgabriel:matrix.mit.edu} Processed request: 0.027sec/0.000sec (0.000sec, 0.000sec) (0.000sec/0.017sec/1) 554B 200 "POST /_matrix/client/r0/user_directory/search HTTP/1.1" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0" [0 dbevts]

Anything else that would be useful to know?

No response

Related: #12958 (asks for ability to only show local users, this is an in-between)

@clokep
Copy link
Member

clokep commented May 2, 2023

This code was added in #9383. It doesn't actually guarantee that local users come first; it just adds additional weighting (2x) for local users. I think that's my reading at least.

The PR even says:

Note that turning this on doesn't necessarily mean that remote users will always be put below local users, but they should be assuming all other ranking factors (search query match, profile information present etc) are identical.

This does seem to match the docs FWIW:

Defines whether to prefer local users in search query results. If set to true, local users are more likely to appear above remote users when searching the user directory. Defaults to false.


I think (given what I can see from your example) the ones that match the Matrix ID & display name are being weighted higher?

@squahtx squahtx added the T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. label May 3, 2023
@MadLittleMods MadLittleMods changed the title Local users don't always appear first even with prefer_local_users: true Local users don't always appear first even with prefer_local_users: true May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-User-Directory T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
Development

No branches or pull requests

4 participants