mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 09:11:00 +00:00
Fix the tests for the new DocumentsBatchBuilder/Reader
This commit is contained in:
@ -5,7 +5,7 @@ use big_s::S;
|
||||
use heed::EnvOpenOptions;
|
||||
use itertools::Itertools;
|
||||
use maplit::hashset;
|
||||
use milli::documents::{DocumentBatchBuilder, DocumentBatchReader};
|
||||
use milli::documents::{DocumentsBatchBuilder, DocumentsBatchReader};
|
||||
use milli::update::{IndexDocuments, IndexDocumentsConfig, IndexerConfig, Settings};
|
||||
use milli::{AscDesc, Criterion, Index, Member, Search, SearchResult};
|
||||
use rand::Rng;
|
||||
@ -393,8 +393,7 @@ fn criteria_ascdesc() {
|
||||
let mut builder =
|
||||
IndexDocuments::new(&mut wtxn, &index, &config, indexing_config, |_| ()).unwrap();
|
||||
|
||||
let mut cursor = Cursor::new(Vec::new());
|
||||
let mut batch_builder = DocumentBatchBuilder::new(&mut cursor).unwrap();
|
||||
let mut batch_builder = DocumentsBatchBuilder::new(Vec::new());
|
||||
|
||||
(0..ASC_DESC_CANDIDATES_THRESHOLD + 1).for_each(|_| {
|
||||
let mut rng = rand::thread_rng();
|
||||
@ -412,16 +411,17 @@ fn criteria_ascdesc() {
|
||||
"age": age,
|
||||
});
|
||||
|
||||
let json = Cursor::new(serde_json::to_vec(&json).unwrap());
|
||||
batch_builder.extend_from_json(json).unwrap();
|
||||
let object = match json {
|
||||
serde_json::Value::Object(object) => object,
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
batch_builder.append_json_object(&object).unwrap();
|
||||
});
|
||||
|
||||
batch_builder.finish().unwrap();
|
||||
|
||||
cursor.set_position(0);
|
||||
|
||||
let reader = DocumentBatchReader::from_reader(cursor).unwrap();
|
||||
let vector = batch_builder.into_inner().unwrap();
|
||||
|
||||
let reader = DocumentsBatchReader::from_reader(Cursor::new(vector)).unwrap();
|
||||
builder.add_documents(reader).unwrap();
|
||||
builder.execute().unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user