stop reindexing by chunk during complete reindexing

This commit is contained in:
qdequele 2020-02-27 14:51:29 +01:00
parent 06ace88901
commit 250aeaa86c
No known key found for this signature in database
GPG Key ID: B3F0A000EBF11745

View File

@ -279,19 +279,17 @@ pub fn reindex_all_documents(writer: &mut heed::RwTxn<MainT>, index: &store::Ind
index.postings_lists.clear(writer)?;
index.docs_words.clear(writer)?;
// 3. re-index chunks of documents (otherwise we make the borrow checker unhappy)
for documents_ids in documents_ids_to_reindex.chunks(100) {
let stop_words = match index.main.stop_words_fst(writer)? {
Some(stop_words) => stop_words,
None => fst::Set::default(),
};
let number_of_inserted_documents = documents_ids.len();
let number_of_inserted_documents = documents_ids_to_reindex.len();
let mut indexer = RawIndexer::new(stop_words);
let mut ram_store = HashMap::new();
for document_id in documents_ids {
for result in index.documents_fields.document_fields(writer, *document_id)? {
for document_id in documents_ids_to_reindex {
for result in index.documents_fields.document_fields(writer, document_id)? {
let (field_id, bytes) = result?;
let value: serde_json::Value = serde_json::from_slice(bytes)?;
ram_store.insert((document_id, field_id), value);
@ -302,7 +300,7 @@ pub fn reindex_all_documents(writer: &mut heed::RwTxn<MainT>, index: &store::Ind
writer,
field_id,
&schema,
*docid,
docid,
index.documents_fields,
index.documents_fields_counts,
&mut indexer,
@ -320,7 +318,6 @@ pub fn reindex_all_documents(writer: &mut heed::RwTxn<MainT>, index: &store::Ind
number_of_inserted_documents,
indexer,
)?;
}
index.main.put_schema(writer, &schema)?;