public void index(String uniqueId, long timestamp, org.bson.Document mongoDocument, List<Metadata> metadataList) throws Exception {
reopenIndexWritersIfNecessary();
Document luceneDocument = new Document();
addStoredFieldsForDocument(mongoDocument, luceneDocument);
luceneDocument.add(new StringField(LumongoConstants.ID_FIELD, uniqueId, Store.YES));
luceneDocument.add(new LongPoint(LumongoConstants.TIMESTAMP_FIELD, timestamp));
luceneDocument.add(new StoredField(LumongoConstants.TIMESTAMP_FIELD, timestamp));
if (indexConfig.getIndexSettings().getStoreDocumentInIndex()) {
luceneDocument.add(new StoredField(LumongoConstants.STORED_DOC_FIELD, new BytesRef(LumongoUtil.mongoDocumentToByteArray(mongoDocument))));
org.bson.Document metadataMongoDoc = new org.bson.Document();
for (Metadata metadata : metadataList) {
metadataMongoDoc.put(metadata.getKey(), metadata.getValue());
}
luceneDocument.add(new StoredField(LumongoConstants.STORED_META_FIELD, new BytesRef(LumongoUtil.mongoDocumentToByteArray(metadataMongoDoc))));
}
luceneDocument = facetsConfig.build(taxoWriter, luceneDocument);
Term term = new Term(LumongoConstants.ID_FIELD, uniqueId);
indexWriter.updateDocument(term, luceneDocument);
possibleCommit();
}