element-hq / element-hq/synapse

Search is broken after message edits

Open
#17,118 2 comments 1 reaction 0 assignees View on GitHub
A-Message-Search A-Search O-Occasional S-Minor T-Defect z-WTF
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

### Description

I was pointed here from this Element issue: https://github.com/element-hq/element-web/issues/27386

This happens on matrix.org using app.element.io and on our self-hosted instance.
It happens in encrypted and unencrypted rooms.

### Steps to reproduce

### Steps to reproduce (using Element (Desktop/Web) v1.11.65)

1. Create a new room
2. Send message: `foo`
3. Send message: `bar`
4. Search for `foo` or `bar` works :heavy_check_mark:
5. Edit the `bar` message: `bar` -> `foo`

### Outcome

#### What did you expect?
6. Search for `foo` shows 2 `foo` results
7. Search for `bar` shows nothing (I think I would not expect to find the original message before the edit)
#### What happened instead?
6. Search for `foo`: shows nothing (`No more results`)
7. Search for `bar`: shows 2(1) `foo` result (I think it only finds 1 message and the other is shown as surrounding text)

### Homeserver

matrix.org, phys.ethz.ch

### Synapse Version

1.105.1

### Installation Method

pip (from PyPI)

### Database

PostgreSQL

### Workers

Multiple workers

### Platform

Debian 12 VM

### Configuration

none

### Relevant log output

```shell
exmaple.com:443 1.2.3.4 - - [24/Apr/2024:13:00:10 +0200] "POST /_matrix/client/v3/search HTTP/2.0" 200 78 305 0.017 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" TLSv1.3 TLS_AES_128_GCM_SHA256
```
```

### Anything else that would be useful to know?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the report with the listed Element Desktop/Web steps, using an edited message in both encrypted and unencrypted rooms. Inspect the POST /_matrix/client/v3/search behavior and compare searches for the original and edited terms. Done means the edited message is indexed under its current text and the original text no longer produces a result.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
backend, databases, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.