Fixes for elasticsearch 8 (#52)
[akkoma] / docs / configuration / search.md
index 7dbbd3e175f37e60f9b4a347aab5c8b820c23bc8..3c5611309b05fe50af43f4d5b31ca14bec8c272b 100644 (file)
@@ -25,16 +25,22 @@ To use [meilisearch](https://www.meilisearch.com/), set the search module to `Pl
 
 > config :pleroma, Pleroma.Search, module: Pleroma.Search.Meilisearch
 
-You then need to set the address of the meilisearch instance, and optionally the private key for authentication.
+You then need to set the address of the meilisearch instance, and optionally the private key for authentication. You might
+also want to change the `initial_indexing_chunk_size` to be smaller if you're server is not very powerful, but not higher than `100_000`,
+because meilisearch will refuse to process it if it's too big. However, in general you want this to be as big as possible, because meilisearch
+indexes faster when it can process many posts in a single batch.
 
 > config :pleroma, Pleroma.Search.Meilisearch,
 >    url: "http://127.0.0.1:7700/",
->    private_key: "private key"
+>    private_key: "private key",
+>    initial_indexing_chunk_size: 100_000
 
 Information about setting up meilisearch can be found in the
 [official documentation](https://docs.meilisearch.com/learn/getting_started/installation.html).
-You probably want to start it with `MEILI_NO_ANALYTICS=true` and `MEILI_NO_CENTRY=true` environment variables,
-to disable analytics.
+You probably want to start it with `MEILI_NO_ANALYTICS=true` environment variable to disable analytics.
+At least version 0.25.0 is required, but you are strongly adviced to use at least 0.26.0, as it introduces
+the `--enable-auto-batching` option which drastically improves performance. Without this option, the search
+is hardly usable on a somewhat big instance.
 
 ### Private key authentication (optional)
 
@@ -43,15 +49,15 @@ you have to get the _private key_, which is actually used for authentication.
 
 === "OTP"
     ```sh
-    ./bin/pleroma_ctl search.meilisearch show-private-key <your master key here>
+    ./bin/pleroma_ctl search.meilisearch show-keys <your master key here>
     ```
 
 === "From Source"
     ```sh
-    mix pleroma.search.meilisearch show-private-key <your master key here>
+    mix pleroma.search.meilisearch show-keys <your master key here>
     ```
 
-This is the key you actually put into your configuration file.
+You will see a "Default Admin API Key", this is the key you actually put into your configuration file.
 
 ### Initial indexing
 
@@ -115,3 +121,45 @@ This will clear **all** the posts from the search index. Note, that deleted post
 there is no need to actually clear the whole index, unless you want **all** of it gone. That said, the index does not hold any information
 that cannot be re-created from the database, it should also generally be a lot smaller than the size of your database. Still, the size
 depends on the amount of text in posts.
+
+## Elasticsearch
+
+**Note: This requires at least ElasticSearch 7**
+
+As with meilisearch, this can be rather memory-hungry, but it is very good at what it does.
+
+To use [elasticsearch](https://www.elastic.co/), set the search module to `Pleroma.Search.Elasticsearch`:
+
+> config :pleroma, Pleroma.Search, module: Pleroma.Search.Elasticsearch
+
+You then need to set the URL and authentication credentials if relevant.
+
+> config :pleroma, Pleroma.Search.Elasticsearch.Cluster,
+>    url: "http://127.0.0.1:9200/",
+>    username: "elastic",
+>    password: "changeme",
+
+### Initial indexing
+
+After setting up the configuration, you'll want to index all of your already existsing posts. Only public posts are indexed.  You'll only
+have to do it one time, but it might take a while, depending on the amount of posts your instance has seen. 
+
+The sequence of actions is as follows:
+
+1. First, change the configuration to use `Pleroma.Search.Elasticsearch` as the search backend
+2. Restart your instance, at this point it can be used while the search indexing is running, though search won't return anything
+3. Start the initial indexing process (as described below with `index`),
+   and wait until the task says it sent everything from the database to index
+4. Wait until the index tasks exits
+
+To start the initial indexing, run the `build` command:
+
+=== "OTP"
+```sh
+./bin/pleroma_ctl search import activities
+```
+
+=== "From Source"
+```sh
+mix pleroma.search import activities
+```