2016-06-26 18:32:54 +02:00
|
|
|
# Full-text search
|
|
|
|
|
|
|
|
Zulip supports full-text search, which can be combined arbitrarily
|
2021-08-20 21:53:28 +02:00
|
|
|
with Zulip's full suite of narrowing operators. By default, it only
|
2016-06-26 18:32:54 +02:00
|
|
|
supports English text, but there is an experimental
|
2020-03-27 01:32:21 +01:00
|
|
|
[PGroonga](https://pgroonga.github.io/) integration that provides
|
2016-06-26 18:32:54 +02:00
|
|
|
full-text search for all languages.
|
|
|
|
|
|
|
|
The user interface and feature set for Zulip's full-text search is
|
2017-02-01 02:44:19 +01:00
|
|
|
documented in the "Search operators" documentation section in the Zulip
|
2016-06-26 18:32:54 +02:00
|
|
|
app's gear menu.
|
|
|
|
|
|
|
|
## The default full-text search implementation
|
|
|
|
|
2022-07-07 07:48:41 +02:00
|
|
|
Zulip uses [PostgreSQL's built-in full-text search
|
2020-03-27 01:32:21 +01:00
|
|
|
feature](https://www.postgresql.org/docs/current/textsearch.html),
|
2016-06-26 18:32:54 +02:00
|
|
|
with a custom set of English stop words to improve the quality of the
|
|
|
|
search results.
|
|
|
|
|
|
|
|
In order to optimize the performance of delivering messages, the
|
|
|
|
full-text search index is updated for newly sent messages in the
|
2021-08-20 21:53:28 +02:00
|
|
|
background, after the message has been delivered. This background
|
2016-06-26 18:32:54 +02:00
|
|
|
updating is done by
|
|
|
|
`puppet/zulip/files/postgresql/process_fts_updates`, which is usually
|
|
|
|
deployed on the database server, but could be deployed on an
|
|
|
|
application server instead.
|
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
## Multi-language full-text search
|
2016-06-26 18:32:54 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
Zulip also supports using [PGroonga](https://pgroonga.github.io/) for
|
|
|
|
full-text search. While PostgreSQL's built-in full-text search feature
|
|
|
|
supports only one language at a time (in Zulip's case, English), the
|
|
|
|
PGroonga full-text search engine supports all languages
|
2021-08-20 21:53:28 +02:00
|
|
|
simultaneously, including Japanese and Chinese. Once we have tested
|
2020-10-27 01:02:21 +01:00
|
|
|
this new backend sufficiently, we expect to switch Zulip deployments
|
|
|
|
to always use PGroonga.
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
### Enabling PGroonga
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
All steps in this section should be run as the `root` user; on most installs, this can be done by running `sudo -i`.
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Alter the deployment setting:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
crudini --set /etc/zulip/zulip.conf machine pgroonga enabled
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Update the deployment to respect that new setting:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
/home/zulip/deployments/current/scripts/zulip-puppet-apply
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Edit `/etc/zulip/settings.py`, to add:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```python
|
|
|
|
USING_PGROONGA = True
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Apply the PGroonga migrations:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga'
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
Note that the migration may take a long time, and users will be
|
|
|
|
unable to send new messages until the migration finishes.
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Once the migrations are complete, restart Zulip:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
su zulip -c '/home/zulip/deployments/current/scripts/restart-server'
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
### Disabling PGroonga
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Remove the PGroonga migration:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
su zulip -c '/home/zulip/deployments/current/manage.py migrate pgroonga zero'
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 22:54:08 +02:00
|
|
|
If you intend to re-enable PGroonga later, you can skip this step,
|
|
|
|
at the cost of your Message table being slightly larger than it would
|
|
|
|
be otherwise.
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Edit `/etc/zulip/settings.py`, editing the line containing `USING_PGROONGA` to read:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```python
|
|
|
|
USING_PGROONGA = False
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Restart Zulip:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
su zulip -c '/home/zulip/deployments/current/scripts/restart-server'
|
|
|
|
```
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2020-10-27 01:02:21 +01:00
|
|
|
1. Finally, remove the deployment setting:
|
2016-04-24 17:08:51 +02:00
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
|
|
|
crudini --del /etc/zulip/zulip.conf machine pgroonga
|
|
|
|
```
|