Fix ElasticSearch documentation

This commit is contained in:
Eugen Rochko 2020-07-26 22:55:38 +02:00
parent 9a756a0947
commit 1b2f466db1
2 changed files with 22 additions and 29 deletions

View File

@ -7,13 +7,9 @@ menu:
parent: admin
---
{{< hint style="warning" >}}
This page is under construction.
{{< /hint >}}
Mastodon uses environment variables as its configuration.
For convenience, it can read them from a flat file called `.env.production` in the Mastodon directory, but they can always be overridden by a specific process. For example, systemd service files can read environment variables from an `EnvironmentFile` or from inline definitions with `Environment`, so you can have different configuration parameters for specific services. They can also be specified when calling Mastodon from the command line.
For convenience, it can read them from a flat file called `.env.production` in the Mastodon directory (called a "dotenv" file), but they can always be overridden by a specific process. For example, systemd service files can read environment variables from an `EnvironmentFile` or from inline definitions with `Environment`, so you can have different configuration parameters for specific services. They can also be specified when calling Mastodon from the command line.
## Basic {#basic}
@ -159,7 +155,7 @@ By default, Mastodon uses the prepared statements feature of PostgreSQL, which o
The streaming API can be deployed to a different domain/subdomain. This may improve the performance of the streaming API as in the default configuration long-lived streaming API requests are proxied through nginx, while serving the streaming API from a different domain/subdomain would allow one to skip nginx entirely.
Example: `wss://streaming.example.com`
Example value: `wss://streaming.example.com`
#### `STREAMING_CLUSTER_NUM`
@ -261,8 +257,15 @@ Useful if the ElasticSearch server is shared between multiple projects or differ
### StatsD {#statsd}
* `STATSD_ADDR`
* `STATSD_NAMESPACE`
#### `STATSD_ADDR`
If set, Mastodon will log some events and metrics into a StatsD instance identified by its hostname and port.
Example value: `localhost:8125`
#### `STATSD_NAMESPACE`
If set, all StatsD keys will be prefixed with this. Defaults to `Mastodon.production` when `RAILS_ENV` is `production`, `Mastodon.development` when it's `development`, etc.
## Limits {#limits}

View File

@ -52,40 +52,30 @@ ES_HOST=localhost
ES_PORT=9200
```
If you have multiple Mastodon servers on the same machine, and you are planning to use the same ElasticSearch installation for all of them, make sure that all of them have unique `REDIS_NAMESPACE` in their configurations, to differentiate the indices. If you need to override the prefix of the ElasticSearch index, you can set `ES_PREFIX` directly.
If you have multiple Mastodon servers on the same machine, and you are planning to use the same ElasticSearch installation for all of them, make sure that all of them have unique `REDIS_NAMESPACE` in their configurations, to differentiate the indices. If you need to override the prefix of the ElasticSearch indices, you can set `ES_PREFIX` directly.
After saving the new configuration, create the index in ElasticSearch with:
```bash
RAILS_ENV=production bundle exec rake chewy:upgrade
```
Then restart Mastodon processes for the new configuration to take effect:
After saving the new configuration, restart Mastodon processes for it to take effect:
```bash
systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
```
Now new statuses will be written to the ElasticSearch index. The last step is importing all of the old data as well. This might take a long while:
Now it's time to create the ElasticSearch indices and fill them with data:
```bash
RAILS_ENV=production bundle exec rake chewy:sync
RAILS_ENV=production bin/tootctl search deploy
```
{{< hint style="warning" >}}
**Compatibility note:** There is a known bug in Ruby 2.6.0 that prevents the above task from working. Other versions of Ruby, such as 2.6.1, are fine.
{{< /hint >}}
## Search optimization for other languages
### Chinese search optimization {#chinese-search-optimization}
The default analyzer of the ElasticSearch is the standard analyzer, which may not be the best especially for Chinese. To improve search experience, you can install language specific analyzer. Before create the index in ElasticSearch:
The default analyzer of the ElasticSearch is the standard analyzer, which may not be the best especially for Chinese. To improve search experience, you can install a language specific analyzer. Before creating the indices in ElasticSearch, install the following ElasticSearch extensions:
Installing [elasticsearch-analysis-ik](https://github.com/medcl/elasticsearch-analysis-ik), [elasticsearch-analysis-stconvert](https://github.com/medcl/elasticsearch-analysis-stconvert) to ElasticSearch.
- [elasticsearch-analysis-ik](https://github.com/medcl/elasticsearch-analysis-ik)
- [elasticsearch-analysis-stconvert](https://github.com/medcl/elasticsearch-analysis-stconvert)
And do modify as follows:
And then modify Mastodon's index definition as follows:
```diff
diff --git a/app/chewy/accounts_index.rb b/app/chewy/accounts_index.rb
@ -99,7 +89,7 @@ diff --git a/app/chewy/accounts_index.rb b/app/chewy/accounts_index.rb
+ tokenizer: 'ik_max_word',
filter: %w(lowercase asciifolding cjk_width),
},
diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb
--- a/app/chewy/statuses_index.rb
+++ b/app/chewy/statuses_index.rb
@ -134,7 +124,7 @@ diff --git a/app/chewy/tags_index.rb b/app/chewy/tags_index.rb
--- a/app/chewy/tags_index.rb
+++ b/app/chewy/tags_index.rb
@@ -2,10 +2,19 @@
class TagsIndex < Chewy::Index
settings index: { refresh_interval: '15m' }, analysis: {
+ char_filter: {
@ -152,7 +142,7 @@ diff --git a/app/chewy/tags_index.rb b/app/chewy/tags_index.rb
filter: %w(lowercase asciifolding cjk_width),
+ char_filter: %w(tsconvert),
},
edge_ngram: {
```