<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 9pt; font-family: Verdana,Geneva,sans-serif'>
<p>I found the solution o this using<strong> seq_range_array_add(&result->definite_uids, uid);</strong></p>
<p>Now, I can see in the logs that several times, the dovecot calls the fts_backend_xapian_update_set_mailbox with box == NULL. WHy so ?</p>
<p>THank you</p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<div id="signature"> </div>
<p><br /></p>
<p id="reply-intro">On 2019-01-12 21:40, Joan Moreau via dovecot wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<p>I somehow fixed the folder issue. (seems some unix rights after too many tests)</p>
<p><br /></p>
<p>Getting back on the "fts_results" structure:</p>
<p>I am trying:</p>
<p><strong><span style="font-family: courier new, courier, monospace;">i_array_init(&(result->definite_uids),r->size);</span></strong><br /><strong><span style="font-family: courier new, courier, monospace;">i_array_init(&(result->maybe_uids),0);</span></strong></p>
<p><span style="font-family: courier new, courier, monospace;">uint32_t uid;</span><br /><span style="font-family: courier new, courier, monospace;">for(i=0;i<r->size;i++)</span><br /><span style="font-family: courier new, courier, monospace;">{</span><br /><span style="font-family: courier new, courier, monospace;"> try</span><br /><span style="font-family: courier new, courier, monospace;"> {</span><br /><span style="font-family: courier new, courier, monospace;"> uid=atol(backend->dbr->get_document(r->data[i]).get_value(1).c_str());</span><br /><span style="font-family: courier new, courier, monospace;"> i_warning("Rresult UID=%d",uid);</span><br /><strong><span style="font-family: courier new, courier, monospace;"> array_idx_set(&(result->definite_uids),i,&uid);</span></strong><br /><span style="font-family: courier new, courier, monospace;"> }</span><br /><span style="font-family: courier new, courier, monospace;"> catch(Xapian::Error e)</span><br /><span style="font-family: courier new, courier, monospace;"> {</span><br /><span style="font-family: courier new, courier, monospace;"> i_warning(e.get_msg().c_str());</span><br /><span style="font-family: courier new, courier, monospace;"> }</span><br /><span style="font-family: courier new, courier, monospace;">}</span></p>
<p>I can see in hte log that UID are properly found on Xapian database, but no results are transmitted to dovecot and to the imap client (roundcube in my case)</p>
<p><br /></p>
<p>Help please :)</p>
<p><br /></p>
<div id="signature"> </div>
<p><br /></p>
<p id="reply-intro">On 2019-01-12 18:15, Joan Moreau wrote:</p>
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">
<p>additionally, my logic is that the backend stores one databalse per mailox in /xapian-indexes (in the "root" dir of the user), the name od the database is the GUID of the mailbox</p>
<p>For INBOX, that works perfectly, and database is properly createdm and backed starts indexing all emails</p>
<p>For other folder, somehow, the process can not access that (root) folder.</p>
<p>Am I missing something ?</p>
<p><br /></p>
<div id="signature"> </div>
<p><br /></p>
<p id="reply-intro">On 2019-01-12 17:37, Joan Moreau wrote:</p>
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">
<p>THank you</p>
<p>Now, for the results</p>
<p>I see the member of fts_result is :</p>
<p>ARRAY_TYPE(seq_range) definite_uids;</p>
<div id="signature"> </div>
<p>I have the UID as a aray of uint32_t *</p>
<p>How to put my UIDs into this "definite_uids" ? Obviously this is not a simple array/pointer. How to say someting similar to result->definite_uids[1]=my_uid ?</p>
<p><br /></p>
<p id="reply-intro">On 2019-01-12 10:25, Timo Sirainen wrote:</p>
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace;">On 11 Jan 2019, at 21.23, Joan Moreau via dovecot <<a href="mailto:dovecot@dovecot.org" rel="noreferrer">dovecot@dovecot.org</a>> wrote:
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;"><br />The below patch resolves the compilation error<br /><br />$ diff -p compat.h compat.h.joan <br />*** compat.h 2019-01-11 20:21:00.726625427 +0100<br />--- compat.h.joan 2019-01-11 20:14:41.729109919 +0100<br />*************** struct iovec;<br />*** 202,207 ****<br />--- 202,211 ----<br />ssize_t i_my_writev(int fd, const struct iovec *iov, int iov_len);<br />#endif<br /><br />+ #ifdef __cplusplus<br />+ extern "C" {<br />+ #endif<br /><br /></blockquote>
<br />You should put this extern "C" into the C++ file you're creating. See for example how fts-lucene/lucene-wrapper.cc does this.<br /><br />
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">1 - WHat does represent "subargs" in mail_search_args</blockquote>
<br />It's set only for SEARCH_OR and SEARCH_SUB. So for example:<br /><br />SEARCH TEXT foo TEXT bar TEXT baz<br /><br />results in:<br /><br />type=SEARCH_SUB<br />value.subargs = (<br /> { type=SEARCH, value.str="foo" },<br /> { type=SEARCH, value.str="bar" },<br /> { type=SEARCH, value.str="baz" },<br />)<br /><br />Or similarly if there's SEARCH OR foo OR TEXT bar TEXT baz or some other combination of OR/ANDs.<br />
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">2 - for rescan : who is responsible for passing again the new email ? Is<br />the Dovecot core sending again all the emails to index ? or the fts<br />shall somehow access the mailbox and read all emails ? Wouldn't just be<br />saying "delete all index and get_last_uid is now 0" the easy way ? or<br />the fts must process all emails (and block the current thread as a<br />mailbx maybe quite large)</blockquote>
<br />The next indexing run is responsible for it. If you return get_last_uid=0, then indexer starts feeding you all mails. So fts backend doesn't have to know about it.<br /><br />
<blockquote style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0;">3 - for get_last_uid : this uncertainity is very unclear. "If there is a<br />gap, then indexer first indexes all the missing" -> this mean at a<br />certain point, indexer maybe rebuilding a previous email, so *last* uid<br />is something different than max. And how indexer does know whther there<br />is a gap wihtout callong the fts backend (whch it does not as there are<br />no function for that) ?</blockquote>
<br />I mean if get_last_uid() returns for example 100, it means that UIDs 1..100 have been indexed by the FTS backend. It's possible that at this point there are already mails with UIDs 101..200 in the folder. So when UID=201 is delivered, indexer notices that FTS backend has only UIDs 1..100 indexed so far, and starts feeding it UIDs 101..201 in that order.<br /><br />You can implement get_last_uid() simply by keeping track of it in dovecot.index* files, similar to how Lucene and Solr already do it with fts_index_get_header() / fts_index_set_header(). They also have a fallback that if the index doesn't have the last_uid value, they do a slower search from the Lucene/Solr index to find the last UID.<br /><br /><br /></div>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body></html>