Microblogi: A very long article Wikipedia article on the orientation of toilet paper [7. kes klo 22:52] [V]

Torstai, 23. helmikuuta 2023

Full-Text Search in Database For Mastodon

Käännös: [ Google ]

Kategoriat: [ ATK ]

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.

[ Postattu 23. helmikuuta 2023 klo 14.56 | ei kommenttia | ]

Trackback osoite

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

Kommentit

Ei kommenttia

Lisää kommentejä

Voit käyttää seuraavat HTML tagit: <p>, <br>, <em> <strong>, <pre>. URL:t jotka alkaavat http://-lla muuttuvat automatisesti hyperlinkkeiksi.

(harkinnanvarainen)
(harkinnanvarainen)


Tallena nimeni ja URL/s-posti ensi kerralle

13 - 7 =