Microblog : A very long article Wikipedia article on the orientation of toilet paper [7 jun à 22:52] [R]

Jeudi, 23 février 2023

Full-Text Search in Database For Mastodon

Traduction: [ Google | Babelfish ]

Catégories : [ Informatique ]

I run my own instance of Mastodon on a server with little memory, i.e. not enough to be able to run ElasticSearch in addition to Mastodon. This means that I cannot do a full-text search on my toots (which would have come handy from time to time).

As an alternative solution, I have implemented a full-text search on database. It is most probably not suitable to use on a large instance, as the implementation uses an SQL query with multiple LIKE conditions ORed together. That's not the most efficient way of querying a database, but for a small enough number of statuses (40k at the moment), it's probably good enough.

This feature is (and will probably forever remain) experimental, but if you want to give it a try, and assuming that you have installed Mastodon from Git like me in /home/mastodon/live and run v4.1.0, here's how to do it.

As user mastodon, run:
$ cd /home/mastodon/live
$ git remote add db_search https://weber.fi.eu.org/software/mastodon
$ git fetch db_search
$ git checkout v4.1.0+db_search.1
$ echo "FULL_TEXT_DB_SEARCH=true" >> .env.production
Then restart the mastodon-web service by running as root:
systemctl restart mastodon-web.service

Reload the mastodon Web UI in your web browser. When you click on the search box, you should now see a message like “Simple text returns posts you have written…” and searching with words you know you have written should display matching toots.

EDIT: I expanded the search to also consider the descriptions of media attachments. The updated version is available as tag v4.1.0+db_search.1.

[ Posté le 23 février 2023 à 14:56 | pas de commentaire | ]

Adresse de trackback

https://weber.fi.eu.org/blog/Informatique/full-text_search_in_database_for_mastodon.trackback

Commentaires

Aucun commentaire

Ajouter un commentaire

Vous pouvez utiliser les balises HTML suivantes: <p>, <br>, <em> <strong>, <pre>. Les URLs commençant par http:// seront automatiquement transformées en liens hypertextes.

(optionnel)
(optionnel)


Sauver mon nom et mon URL/Email pour la prochaine fois

11 - 7 =