mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-09 22:48:54 +01:00
Show the actual number of actually edited documents
This commit is contained in:
parent
246f0e7130
commit
2fae96ac14
@ -41,7 +41,7 @@ use crate::update::{
|
|||||||
IndexerConfig, UpdateIndexingStep, WordPrefixDocids, WordPrefixIntegerDocids, WordsPrefixesFst,
|
IndexerConfig, UpdateIndexingStep, WordPrefixDocids, WordPrefixIntegerDocids, WordsPrefixesFst,
|
||||||
};
|
};
|
||||||
use crate::vector::EmbeddingConfigs;
|
use crate::vector::EmbeddingConfigs;
|
||||||
use crate::{CboRoaringBitmapCodec, FieldsIdsMap, Index, Object, Result};
|
use crate::{all_obkv_to_json, CboRoaringBitmapCodec, FieldsIdsMap, Index, Object, Result};
|
||||||
|
|
||||||
static MERGED_DATABASE_COUNT: usize = 7;
|
static MERGED_DATABASE_COUNT: usize = 7;
|
||||||
static PREFIX_DATABASE_COUNT: usize = 4;
|
static PREFIX_DATABASE_COUNT: usize = 4;
|
||||||
@ -184,7 +184,7 @@ where
|
|||||||
return Ok((self, Ok(0)));
|
return Ok((self, Ok(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transform every field of a raw obkv store into a JSON Object.
|
/// Transform every field of a raw obkv store into a Rhai Map.
|
||||||
pub fn all_obkv_to_rhaimap(
|
pub fn all_obkv_to_rhaimap(
|
||||||
obkv: obkv::KvReaderU16,
|
obkv: obkv::KvReaderU16,
|
||||||
fields_ids_map: &FieldsIdsMap,
|
fields_ids_map: &FieldsIdsMap,
|
||||||
@ -225,30 +225,33 @@ where
|
|||||||
let mut documents_batch_builder = tempfile::tempfile().map(DocumentsBatchBuilder::new)?;
|
let mut documents_batch_builder = tempfile::tempfile().map(DocumentsBatchBuilder::new)?;
|
||||||
|
|
||||||
for docid in documents {
|
for docid in documents {
|
||||||
let (document, document_id) = match self.index.documents.get(self.wtxn, &docid)? {
|
let (document, document_object, document_id) =
|
||||||
Some(obkv) => {
|
match self.index.documents.get(self.wtxn, &docid)? {
|
||||||
let document_id_bytes = obkv.get(primary_key_id).unwrap();
|
Some(obkv) => {
|
||||||
let document_id: serde_json::Value =
|
let document_id_bytes = obkv.get(primary_key_id).unwrap();
|
||||||
serde_json::from_slice(document_id_bytes).unwrap();
|
let document_id: serde_json::Value =
|
||||||
let document = all_obkv_to_rhaimap(obkv, &fields_ids_map)?;
|
serde_json::from_slice(document_id_bytes).unwrap();
|
||||||
(document, document_id)
|
let document = all_obkv_to_rhaimap(obkv, &fields_ids_map)?;
|
||||||
}
|
let document_object = all_obkv_to_json(obkv, &fields_ids_map)?;
|
||||||
None => panic!("documents must exist"),
|
(document, document_object, document_id)
|
||||||
};
|
}
|
||||||
|
None => panic!("documents must exist"),
|
||||||
|
};
|
||||||
|
|
||||||
let mut scope = Scope::new();
|
let mut scope = Scope::new();
|
||||||
scope.push("doc", document);
|
scope.push("doc", document);
|
||||||
|
|
||||||
let _ = engine.eval_ast_with_scope::<Dynamic>(&mut scope, &ast).unwrap();
|
let _ = engine.eval_ast_with_scope::<Dynamic>(&mut scope, &ast).unwrap();
|
||||||
let new_document = scope.remove("doc").unwrap();
|
let new_document = scope.remove("doc").unwrap();
|
||||||
let new_document = rhaimap_to_object(new_document);
|
let new_document = rhaimap_to_object(new_document);
|
||||||
|
|
||||||
assert_eq!(
|
if document_object != new_document {
|
||||||
Some(&document_id),
|
assert_eq!(
|
||||||
new_document.get(primary_key),
|
Some(&document_id),
|
||||||
"you cannot change the document id when editing documents"
|
new_document.get(primary_key),
|
||||||
);
|
"you cannot change the document id when editing documents"
|
||||||
documents_batch_builder.append_json_object(&new_document)?;
|
);
|
||||||
|
documents_batch_builder.append_json_object(&new_document)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = documents_batch_builder.into_inner()?;
|
let file = documents_batch_builder.into_inner()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user