mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Add some tests to check for the nested documents ids
This commit is contained in:
parent
a892a4a79c
commit
192793ee38
2 changed files with 55 additions and 6 deletions
|
@ -1627,6 +1627,58 @@ mod tests {
|
|||
assert_eq!(documents_ids, vec![3]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retrieve_a_b_nested_document_id() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(10 * 1024 * 1024); // 10 MB
|
||||
let index = Index::new(options, &path).unwrap();
|
||||
let config = IndexerConfig::default();
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut builder = update::Settings::new(&mut wtxn, &index, &config);
|
||||
builder.set_primary_key("a.b".to_owned());
|
||||
builder.execute(|_| ()).unwrap();
|
||||
|
||||
let content = documents!({ "a" : { "b" : { "c" : 1 }}});
|
||||
let indexing_config = IndexDocumentsConfig::default();
|
||||
let builder =
|
||||
IndexDocuments::new(&mut wtxn, &index, &config, indexing_config.clone(), |_| ())
|
||||
.unwrap();
|
||||
let (_builder, user_error) = builder.add_documents(content).unwrap();
|
||||
|
||||
// There must be an issue with the primary key no present in the given document
|
||||
user_error.unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retrieve_a_b_c_nested_document_id() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(10 * 1024 * 1024); // 10 MB
|
||||
let index = Index::new(options, &path).unwrap();
|
||||
let config = IndexerConfig::default();
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut builder = update::Settings::new(&mut wtxn, &index, &config);
|
||||
builder.set_primary_key("a.b.c".to_owned());
|
||||
builder.execute(|_| ()).unwrap();
|
||||
|
||||
let content = documents!({ "a" : { "b" : { "c" : 1 }}});
|
||||
let indexing_config = IndexDocumentsConfig::default();
|
||||
let builder =
|
||||
IndexDocuments::new(&mut wtxn, &index, &config, indexing_config.clone(), |_| ())
|
||||
.unwrap();
|
||||
let (builder, user_error) = builder.add_documents(content).unwrap();
|
||||
user_error.unwrap();
|
||||
builder.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
let external_documents_ids = index.external_documents_ids(&rtxn).unwrap();
|
||||
assert!(external_documents_ids.get("1").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_facets_generation() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue