mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
Fix the merging of documents
This commit is contained in:
parent
e639ec79d1
commit
6526ce1208
@ -210,17 +210,22 @@ fn merge_document_for_updates(
|
|||||||
let current = index.documents.remap_data_type::<Bytes>().get(rtxn, &docid)?;
|
let current = index.documents.remap_data_type::<Bytes>().get(rtxn, &docid)?;
|
||||||
let current: Option<&KvReaderFieldId> = current.map(Into::into);
|
let current: Option<&KvReaderFieldId> = current.map(Into::into);
|
||||||
|
|
||||||
|
if operations.is_empty() {
|
||||||
|
return Ok(None); // but it's strange
|
||||||
|
}
|
||||||
|
|
||||||
|
let last_deletion = operations.iter().rposition(|op| matches!(op, InnerDocOp::Deletion));
|
||||||
|
let operations = &operations[last_deletion.map_or(0, |i| i + 1)..];
|
||||||
|
|
||||||
|
// If there was a deletion we must not start
|
||||||
|
// from the original document but from scratch.
|
||||||
|
if last_deletion.is_none() {
|
||||||
if let Some(current) = current {
|
if let Some(current) = current {
|
||||||
current.into_iter().for_each(|(k, v)| {
|
current.into_iter().for_each(|(k, v)| {
|
||||||
document.insert(k, v.into());
|
document.insert(k, v.into());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let last_deletion =
|
|
||||||
operations.iter().rposition(|operation| matches!(operation, DocumentOperation::Deletion));
|
|
||||||
|
|
||||||
let operations = &operations[last_deletion.map_or(0, |i| i + 1)..];
|
|
||||||
|
|
||||||
if operations.is_empty() {
|
if operations.is_empty() {
|
||||||
match current {
|
match current {
|
||||||
Some(current) => {
|
Some(current) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user