woj-tek commented on PR #2342:
URL: https://github.com/apache/james-project/pull/2342#issuecomment-2281194189

   tl,dr;
   
   It seems that re-adding ID field (akin to re-adding `UID_FIELD`) in 
`org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex#update()` 
fixes the issue (MTP test are all green):
   ```
   final String text = doc.get(ID_FIELD);
   doc.add(new StringField(ID_FIELD, text, Store.YES));
   ```
   
   Could someone verify it? :)
   
   ---
   
   OK, my previous comment was off, but I've been digging into it more and more 
(and learning Lucene), running simpler tests (even just in Lucene). I even 
wrote on Lucene mailing list :)
   
   In general, as per information from the list re-opening the reader *should* 
be enough:
   
   > When you open an IndexReader, it is locked to the view of the Lucene
   directory at the time that it's opened.
   > 
   > If you make changes, you'll need to open a new IndexReader before those
   changes are visible. I see that you tried creating a new IndexSearcher, but
   unfortunately that's not sufficient.
   
   What I noticed when running the tests was that adding the mail+flag document 
works and then *first* update of the flag works as well. Only subsequent 
updates fail.
   
   This made me thing that for some reason `new Term(ID_FIELD, 
doc.get(ID_FIELD))` has to be failing and indeed when looking for documents 
manually (new IndexReader) it doesn't yield results for newly updated documents 
as if those IDs weren't matched (but they are visible in the debugger and 
string output!).
   
   So I decide to explicitly re-apply the ID when updating as it was done with 
the UID field: `doc.add(new StringField(doc.get(ID_FIELD), text, Store.YES));` 
and it seems that this address the issue (?!)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to