To start off, we need to install some packages:
apt install build-essential git
apt install dovecot-dev libicu-dev libxapian-dev libsqlite3-dev
Then let's clone the fts-xapian git repository:
git clone https://github.com/grosjo/fts-xapian
cd fts-xapian
Let's compile...
autoreconf -vi
./configure --with-dovecot=/usr/lib/dovecot
make
sudo make install
"/usr/lib/dovecot" is the base directory of /usr/lib/dovecot/dovecot-config, installed by dovecot-dev. Update your dovecot.conf as described.
And finally, if it's not a fresh install
# Just index all mailboxes of all users
doveadm index -A -q \*
# If you want to know what's going on and what "index" is doing:
doveadm -Dv index -u $DOVECOTUSER \*
# or
doveadm -Dv index -u $DOVECOTUSER INBOX