Support merging update and replacement operations

This commit is contained in:
Kerollmops
2025-01-28 11:31:53 +01:00
parent aa2327591e
commit acc400face
2 changed files with 238 additions and 309 deletions

View File

@ -27,7 +27,7 @@ pub struct Update<'doc> {
docid: DocumentId,
external_document_id: &'doc str,
new: Versions<'doc>,
has_deletion: bool,
from_scratch: bool,
}
pub struct Insertion<'doc> {
@ -109,9 +109,9 @@ impl<'doc> Update<'doc> {
docid: DocumentId,
external_document_id: &'doc str,
new: Versions<'doc>,
has_deletion: bool,
from_scratch: bool,
) -> Self {
Update { docid, new, external_document_id, has_deletion }
Update { docid, new, external_document_id, from_scratch }
}
pub fn docid(&self) -> DocumentId {
@ -154,7 +154,7 @@ impl<'doc> Update<'doc> {
index: &'t Index,
mapper: &'t Mapper,
) -> Result<MergedDocument<'_, 'doc, 't, Mapper>> {
if self.has_deletion {
if self.from_scratch {
Ok(MergedDocument::without_db(DocumentFromVersions::new(&self.new)))
} else {
MergedDocument::with_db(
@ -207,7 +207,7 @@ impl<'doc> Update<'doc> {
cached_current = Some(current);
}
if !self.has_deletion {
if !self.from_scratch {
// no field deletion, so fields that don't appear in `updated` cannot have changed
return Ok(changed);
}
@ -257,7 +257,7 @@ impl<'doc> Update<'doc> {
doc_alloc: &'doc Bump,
embedders: &'doc EmbeddingConfigs,
) -> Result<Option<MergedVectorDocument<'doc>>> {
if self.has_deletion {
if self.from_scratch {
MergedVectorDocument::without_db(
self.external_document_id,
&self.new,