From 19f48c15fb24c952b605e751fa62c6ece9f2997d Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 31 Dec 2024 18:00:14 +0100 Subject: [PATCH] Fix the addition of empty payload --- .../update/new/indexer/document_operation.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/milli/src/update/new/indexer/document_operation.rs b/crates/milli/src/update/new/indexer/document_operation.rs index 090c1eb8e..5ccac4297 100644 --- a/crates/milli/src/update/new/indexer/document_operation.rs +++ b/crates/milli/src/update/new/indexer/document_operation.rs @@ -252,6 +252,24 @@ fn extract_addition_payload_changes<'r, 'pl: 'r>( previous_offset = iter.byte_offset(); } + if payload.is_empty() { + let result = retrieve_or_guess_primary_key( + rtxn, + index, + new_fields_ids_map, + primary_key_from_op, + None, + ); + match result { + Ok(Ok((pk, _))) => { + primary_key.get_or_insert(pk); + } + Ok(Err(UserError::NoPrimaryKeyCandidateFound)) => (), + Ok(Err(user_error)) => return Err(Error::UserError(user_error)), + Err(error) => return Err(error), + }; + } + Ok(new_docids_version_offsets) }