mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-09 22:26:29 +00:00
Support merging update and replacement operations
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user