query.add(NumericRangeQuery.newLongRange(UID_FIELD, range.getUidFrom(), range.getUidTo(), true, true), BooleanClause.Occur.MUST);
TopDocs docs = searcher.search(query, 100000);
ScoreDoc[] sDocs = docs.scoreDocs;
for (int i = 0; i < sDocs.length; i++) {
Document doc = searcher.doc(sDocs[i].doc);
doc.removeFields(FLAGS_FIELD);
indexFlags(f, doc);
writer.updateDocument(new Term(ID_FIELD, doc.get(ID_FIELD)), doc);
}
} catch (IOException e) {
throw new MailboxException("Unable to add messages in index", e);