Add search/meilisearch documentation
[akkoma] / docs / configuration / search.md
1 # Configuring search
2
3 {! backend/administration/CLI_tasks/general_cli_task_info.include !}
4
5 ## Built-in search
6
7 To use built-in search that has no external dependencies, set the search module to `Pleroma.Activity`:
8
9 > config :pleroma, Pleroma.Search, module: Pleroma.Activity
10
11 While it has no external dependencies, it has problems with performance and relevancy.
12
13 ## Meilisearch
14
15 To use [meilisearch](https://www.meilisearch.com/), set the search module to `Pleroma.Search.Meilisearch`:
16
17 > config :pleroma, Pleroma.Search, module: Pleroma.Search.Meilisearch
18
19 You then need to set the address of the meilisearch instance, and optionally the private key for authentication.
20
21 > config :pleroma, Pleroma.Search.Meilisearch,
22 > url: "http://127.0.0.1:7700/",
23 > private_key: "private key"
24
25 Information about setting up meilisearch can be found in the
26 [official documentation](https://docs.meilisearch.com/learn/getting_started/installation.html).
27 You probably want to start it with `MEILI_NO_ANALYTICS=true` and `MEILI_NO_CENTRY=true` environment variables,
28 to disable analytics.
29
30 ### Private key authentication (optional)
31
32 To set the private key, use the `MEILI_MASTER_KEY` environment variable when starting. After setting the _master key_,
33 you have to get the _private key_, which is actually used for authentication.
34
35 === "OTP"
36 ```sh
37 ./bin/pleroma_ctl search.meilisearch show-private-key <your master key here>
38 ```
39
40 === "From Source"
41 ```sh
42 mix pleroma.search.meilisearch show-private-key <your master key here>
43 ```
44
45 This is the key you actually put into your configuration file.
46
47 ### Initial indexing
48
49 After setting up the configuration, you'll want to index all of your already existsing posts. Only public posts are indexed. You'll only
50 have to do it one time, but it might take a while, depending on the amount of posts your instance has seen. This is also a fairly RAM
51 consuming process for `meilisearch`, and it will take a lot of RAM when running if you have a lot of posts (seems to be around 5G for ~1.2
52 million posts while idle and up to 7G while indexing initially, but your experience may be different).
53
54 To start te initial indexing, run the `index` command:
55
56 === "OTP"
57 ```sh
58 ./bin/pleroma_ctl search.meilisearch index
59 ```
60
61 === "From Source"
62 ```sh
63 mix pleroma.search.meilisearch index
64 ```
65
66 This will show you the total amount of posts to index, and then show you the amount of posts indexed currently, until the numbers eventually
67 become the same. The posts are indexed in big batches and meilisearch will take some time to actually index them, even after you have
68 inserted all the posts into it. Depending on the amount of posts, this may be as long as several hours. To get information about the status
69 of indexing and how many posts have actually been indexed, use the `stats` command:
70
71 === "OTP"
72 ```sh
73 ./bin/pleroma_ctl search.meilisearch stats
74 ```
75
76 === "From Source"
77 ```sh
78 mix pleroma.search.meilisearch stats
79 ```
80
81 ### Clearing the index
82
83 In case you need to clear the index (for example, to re-index from scratch, if that needs to happen for some reason), you can
84 use the `clear` command:
85
86 === "OTP"
87 ```sh
88 ./bin/pleroma_ctl search.meilisearch clear
89 ```
90
91 === "From Source"
92 ```sh
93 mix pleroma.search.meilisearch clear
94 ```
95
96 This will clear **all** the posts from the search index. Note, that deleted posts are also removed from index by the instance itself, so
97 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
98 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
99 depends on the amount of text in posts.