1

Topic: Full Text Search Dovecot

==== Required information ====
- iRedMail version: 0.8.6
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Linux/BSD distribution name and version: Ubuntu 14.04
- Related log if you're reporting an issue:
====
Hi,

I'd like to know more about how is handled a FTS in Dovecot?

I use K9-mail as my android mua, I enabled server-side search, but find it very inneficient.

Base on Dovecot documentation : http://wiki2.dovecot.org/Plugins/FTS  , either Solr or Lucene can be implemented with Dovecot.

Can I have some feedback on this subject?

Thank you a lot,

Victor.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Full Text Search Dovecot

Unfortunately, i have no experience with FTS yet. sorry. It's better to ask in Dovecot mailing list instead.

3

Re: Full Text Search Dovecot

Ok, thanks for the feedback.

I'll try recompile Dovecot with Lucene support then (Lucene engine should be included in Dovecot starting with ubuntu 14.10)

Another solution is to install Solr (as mentioned in this interesting article : http://sealedabstract.com/code/nsa-proo … -2-hours/) but I really don't want to install Java on my server...

I'll keep you updated when I'll try it.

4

Re: Full Text Search Dovecot

Looking for your practice.

5 (edited by sulliwane 2014-09-20 12:04:29)

Re: Full Text Search Dovecot

Hi,

so I installed Solr on my Ubuntu 14.04 following this guide (https://www.digitalocean.com/community/ … untu-14-04) it's actually pretty easy. But yes of course, it needs java sad

Then I downloaded the dovecot sources (2.2.13) and compiled it with many options found from this page (http://wiki2.dovecot.org/CompilingSource) and from the output of --build-options of my previous dovecot binary.

After compiling, here is the output of my newly compiled binary:
#/usr/local/sbin/dovecot --build-options
Build options: ioloop=epoll notify=inotify ipv6 openssl io_block_size=8192
Mail storages: shared mdbox sdbox maildir mbox cydir imapc pop3c raw fail
SQL drivers: mysql postgresql sqlite
Passdb: checkpassword ldap pam passwd passwd-file shadow sql
Userdb: checkpassword ldap nss passwd prefetch passwd-file sql

I copied my previous (iredmail) config from /etc/dovecot to /usr/local/etc/dovecot, and launched my new dovecot.

First error :
doveconf: Fatal: Error in configuration file /usr/local/etc/dovecot/dovecot.conf: protocols: Unknown protocol: sieve

and with this:

#doveconf -n | head -n1
# 2.2.13: /usr/local/etc/dovecot/dovecot.conf
doveconf: Error: protocols: Unknown protocol: sieve
doveconf: Fatal: Error in configuration file /usr/local/etc/dovecot/dovecot.conf: protocols: Unknown protocol: sieve

I spent 2 hours on this one, verifying the sieve packages was well installed, checking that everything was in the right place. I finally gave up, and removed sieve from the dovecot.conf.

Launched again, and  this time it works. I also had to change some permissions root:dovecot and dovecot:dovecot on a few .conf files. I also fixed the "autocreate" warning by updating the conf as recommended in this thread (http://www.iredmail.org/forum/topic5856 … tting.html)

Now my imap server works again. So as recommended on http://wiki2.dovecot.org/Plugins/FTS/Solr I edited conf.d/10-mail.conf and conf.d/90-plugins.conf, and restarted Dovecot. And tried to start the indexation using :

#doveadm fts rescan -u <username>
doveadm(root): Fatal: Unknown command 'fts', but plugin fts exists. Try to set mail_plugins=fts

Even though I already have mail_plugins = fts fts_solr in my conf.d/10-mails.conf, I added it in dovecot.conf and restarted. Surprise, the error changed !

#doveadm fts rescan -u victor
doveadm(victor): Fatal: User doesn't exist

My question : I have the feeling that eveyrhing in the conf.d folder is not included as it should be in the dovecot.conf ? Moreover, I found that ususaly there is !include conf.d/*.conf statement at the end of dovecot.conf (which is not the case after a iredmail install).

I didn't go further as I feel my skills/experience are too limited at this point, but I'd be keen to receive the advices of a specialist,

Thank you!

6

Re: Full Text Search Dovecot

sulliwane wrote:

My question : I have the feeling that eveyrhing in the conf.d folder is not included as it should be in the dovecot.conf ? Moreover, I found that ususaly there is !include conf.d/*.conf statement at the end of dovecot.conf (which is not the case after a iredmail install).

iRedMail uses just dovecot.conf and not files under conf.d/. You can either add your modifications in dovecot.conf, or add your own 'include' statement to include addition config files.

7

Re: Full Text Search Dovecot

Ok, I didn't know. So I adjusted the settings, and now I try submit the IMAP search instruction, but it doesn't work. Do you know why ?

root@ns3098045:/usr/local/etc/dovecot# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
a LOGIN username password
a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE SEARCH=FUZZY QUOTA] Logged in
SEARCH text "test"
SEARCH BAD Error in IMAP command TEXT: Unknown command.
SEARCH ALL
SEARCH BAD Error in IMAP command ALL: Unknown command.

thank you,

8

Re: Full Text Search Dovecot

Check my practise:

# telnet localhost 143
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

a login user@domain.ltd password
a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE QUOTA] Logged in

a select INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 2 EXISTS
* 0 RECENT
* OK [UNSEEN 1] First unseen.
* OK [UIDVALIDITY 1411302621] UIDs valid
* OK [UIDNEXT 3] Predicted next UID
a OK [READ-WRITE] Select completed (0.000 secs).

a search text "hello"
* SEARCH
a OK Search completed (0.001 secs).
^]
telnet> quit
Connection closed.

9

Re: Full Text Search Dovecot

Ok, thank you. I also realized I missed the "a" at the beginning. So it works now :

a search text "passeport"
* OK Searched 87% of the mailbox, ETA 0:01
* SEARCH 149 150 241 249 271 272
a OK Search completed (13.416 secs).
BAD Error in IMAP command : Unknown command.
a search text "passeport"
* SEARCH 149 150 241 249 271 272
a OK Search completed (4.075 secs).

and here is the dovecot log with solr http request record : https://gist.github.com/sulliwane/6348d … ovecot-log

So the Full Text Search is working fine now. I realize that it was already possible to search for the body using imap search command, but solr make it much more responsive.

I will make a step by step tutorial in the coming days.

Now it seems the only problem left is the SIEVE plugin that doesn't work anymore. Do you have any idea regarding this error ? :

doveconf: Fatal: Error in configuration file /usr/local/etc/dovecot/dovecot.conf: protocols: Unknown protocol: sieve

Thank you again for your help!

10

Re: Full Text Search Dovecot

Personally, i think you should rebuild Ubuntu source package with your addition compile options, then you get all original compile options and solr support, and you can install it with 'apt-get/dpkg/...' directly.

About sieve protocol support, i think you should enable managesieve support in Dovecot compile option. Not quite sure, it's better to check Dovecot build options with Ubuntu source package.

Reference: http://wiki2.dovecot.org/Pigeonhole/ManageSieve

11

Re: Full Text Search Dovecot

Yes, you are right, building from Ubuntu source package was a better idea. I just finished it, and it actually already build with --with-solr option. After compiling, all these packages were created :

dovecot-core_2.2.9-1ubuntu2.1_amd64.deb
dovecot-dbg_2.2.9-1ubuntu2.1_amd64.deb
dovecot-dev_2.2.9-1ubuntu2.1_amd64.deb
dovecot-gssapi_2.2.9-1ubuntu2.1_amd64.deb
dovecot-imapd_2.2.9-1ubuntu2.1_amd64.deb
dovecot-ldap_2.2.9-1ubuntu2.1_amd64.deb
dovecot-lmtpd_2.2.9-1ubuntu2.1_amd64.deb
dovecot-managesieved_2.2.9-1ubuntu2.1_amd64.deb
dovecot-mysql_2.2.9-1ubuntu2.1_amd64.deb
dovecot-pgsql_2.2.9-1ubuntu2.1_amd64.deb
dovecot-pop3d_2.2.9-1ubuntu2.1_amd64.deb
dovecot-sieve_2.2.9-1ubuntu2.1_amd64.deb
dovecot-solr_2.2.9-1ubuntu2.1_amd64.deb
dovecot-sqlite_2.2.9-1ubuntu2.1_amd64.deb
mail-stack-delivery_2.2.9-1ubuntu2.1_all.deb

The one I needed were all already installed by iredmail install. So after reinstalling dovecot-core.dpkg, I just had to install dovecot-solr.dpkg to have solr working ! Nice ! and Sieve works again...

So overhaul it's actually quite easy to get solr and dovecot working together.

I only have one issue remaining :

I moved all my emails from my gmail account to a new account on iredmail called user-gmail (thanks to IMAPSYNC). The transfer worked great and I can now read my gmail mails using dovecot. I have 6go of mails, so the search function is very important (that's mainly for this that I needed solr). But although solr is working fine with my main email account, I get this error with the user-gmail account (from dovecot.log):

Sep 24 15:43:49 indexer-worker: Error: User user-gmail@vxxxxxxx.fr lookup failed: Unknown user
Sep 24 15:43:49 imap(user-gmail@vxxxxxxxx.fr): Error: indexer failed to index mailbox Trash

Do you have any idea about this error?

anyway, thanks a lot for your support and your suggestions that helped me a lot.

12

Re: Full Text Search Dovecot

This is a known issue in iRedMail-0.8.7 and earlier releases. You can fix it by add 'enabledService=indexer-worker' for all users.
We have a script for you to update all users:
http://www.iredmail.org/wiki/index.php? … mail_users

NOTE: this upgrade tutorial is still a draft, do not apply other steps.

13 (edited by sulliwane 2014-09-25 10:45:22)

Re: Full Text Search Dovecot

Ah! great, indexer problem solved thanks to this python script. so seems everything is working nicely now, here is an idea of the speed improve on my 6go+ mailbox for a "passepor" search :

a search text "passeport"
* OK Indexed 4% of the mailbox, ETA 3:52
* OK Indexed 7% of the mailbox, ETA 4:22
* OK Indexed 11% of the mailbox, ETA 3:58
* OK Indexed 17% of the mailbox, ETA 3:14
* OK Indexed 21% of the mailbox, ETA 3:06
* OK Indexed 26% of the mailbox, ETA 2:49
* OK Indexed 30% of the mailbox, ETA 2:42
* OK Indexed 32% of the mailbox, ETA 2:49
* OK Indexed 36% of the mailbox, ETA 2:39
* OK Indexed 40% of the mailbox, ETA 2:29
* OK Indexed 43% of the mailbox, ETA 2:25
* OK Indexed 45% of the mailbox, ETA 2:26
* OK Indexed 47% of the mailbox, ETA 2:26
* OK Indexed 51% of the mailbox, ETA 2:14
* OK Indexed 54% of the mailbox, ETA 2:07
* OK Indexed 58% of the mailbox, ETA 1:55
* OK Indexed 61% of the mailbox, ETA 1:48
* OK Indexed 62% of the mailbox, ETA 1:50
* OK Indexed 62% of the mailbox, ETA 1:56
* OK Indexed 62% of the mailbox, ETA 2:02
* OK Indexed 62% of the mailbox, ETA 2:08
* OK Indexed 62% of the mailbox, ETA 2:14
* OK Indexed 62% of the mailbox, ETA 2:20
* OK Indexed 62% of the mailbox, ETA 2:26
* OK Indexed 62% of the mailbox, ETA 2:33
* OK Indexed 62% of the mailbox, ETA 2:39
* OK Indexed 62% of the mailbox, ETA 2:45
* OK Indexed 62% of the mailbox, ETA 2:51
* OK Indexed 62% of the mailbox, ETA 2:57
* OK Indexed 64% of the mailbox, ETA 2:48
* OK Indexed 65% of the mailbox, ETA 2:46
* OK Indexed 67% of the mailbox, ETA 2:37
* OK Indexed 69% of the mailbox, ETA 2:28
* OK Indexed 73% of the mailbox, ETA 2:05
* OK Indexed 74% of the mailbox, ETA 2:02
* OK Indexed 79% of the mailbox, ETA 1:35
* OK Indexed 83% of the mailbox, ETA 1:15
* OK Indexed 87% of the mailbox, ETA 0:56
* OK Indexed 88% of the mailbox, ETA 0:53
* OK Indexed 92% of the mailbox, ETA 0:34
* OK Indexed 94% of the mailbox, ETA 0:26
* OK Indexed 97% of the mailbox, ETA 0:12
* OK Mailbox indexing finished
* SEARCH 203 213 257 382 383 384 389 393 397 398 414 916 1440 1710 1897 1927 2637 2718 2976 2978 2980 4257 4304 4307 4309 4311 4312 4329 4331 4828 4829 5647 5978 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6752 6918 6919 7382 7833 8471 8975 10233 10302 10864 11895 12227 12410 12427 12474 12863 15983 17377 17729 17730 17777 17778 17969 18478 18730 18737 18738 18739 18740 18742 19210 19217 19223 19434 19458 19513 19672 19768 19799 19800 19803 19964 20439 20442 20459 20460 20462 20464 20465 20466 20467 20469 20470 20481 20482 20483 20484 20492 20493 20494 20495 20496 20512 20522 21263 21341 21342 21355 21356 21372 21424 21481 21489 21490 21491
a OK Search completed (429.548 secs).
a search text "passeport"
* SEARCH 203 213 257 382 383 384 389 393 397 398 414 916 1440 1710 1897 1927 2637 2718 2976 2978 2980 4257 4304 4307 4309 4311 4312 4329 4331 4828 4829 5647 5978 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6752 6918 6919 7382 7833 8471 8975 10233 10302 10864 11895 12227 12410 12427 12474 12863 15983 17377 17729 17730 17777 17778 17969 18478 18730 18737 18738 18739 18740 18742 19210 19217 19223 19434 19458 19513 19672 19768 19799 19800 19803 19964 20439 20442 20459 20460 20462 20464 20465 20466 20467 20469 20470 20481 20482 20483 20484 20492 20493 20494 20495 20496 20512 20522 21263 21341 21342 21355 21356 21372 21424 21481 21489 21490 21491
a OK Search completed (0.028 secs).

429.548 secs before and 0.028 after solr index. that's good smile

thanks again!

14

Re: Full Text Search Dovecot

Cool, the search speed is fast.

15

Re: Full Text Search Dovecot

Hello there, just to say that after a disk crash I had to reinstall everything. And this time I wrote down all the steps for Dovecot 2.2.9, Solr 4.10 and Ubuntu 14.04.

This could interest someone : https://blog.vbonhomme.fr/add-full-text … ntu-14-04/

cheers!

16

Re: Full Text Search Dovecot

Not iRedMail?

17 (edited by sulliwane 2014-11-05 16:47:53)

Re: Full Text Search Dovecot

I wanted to give mailinabox a try. Partly because I didn't need ldap or mysql/phpmyadmin or apache (I'm the only user so sqlite and nginx are good option), and mostly by curiosity...

I still prefer iRedMail as it's a more complete solution (Amavis, iRedAdmin, greylisting can be easily disabled...etc etc) but as the setup is done now, I'm gonna stuck with this config until next time I have to reinstall...

But the steps to enable FTS are exactly the same!

note : I just see 0.9rc is released, and it's a good thing phpmyadmin is not included anymore. As well as nginx support...And I didn't know about http://adminer.org/ , good advice. Keep on the great work!