review the internal schema to allow to create schema without identifier; fix #513

This commit is contained in:
qdequele 2020-03-05 18:29:10 +01:00
parent 16a99aa95e
commit 86c3482cbd
No known key found for this signature in database
GPG key ID: B3F0A000EBF11745
11 changed files with 312 additions and 129 deletions

View file

@ -8,6 +8,7 @@ use crossbeam_channel::{Receiver, Sender};
use heed::types::{Str, Unit};
use heed::{CompactionOption, Result as ZResult};
use log::debug;
use meilisearch_schema::Schema;
use crate::{store, update, Index, MResult};
@ -242,6 +243,7 @@ impl Database {
index.main.put_name(&mut writer, name)?;
index.main.put_created_at(&mut writer)?;
index.main.put_updated_at(&mut writer)?;
index.main.put_schema(&mut writer, &Schema::new())?;
let env_clone = self.env.clone();
let update_env_clone = self.update_env.clone();

View file

@ -115,7 +115,7 @@ pub fn apply_documents_addition<'a, 'b>(
None => return Err(Error::SchemaMissing),
};
let identifier = schema.identifier();
let identifier = schema.identifier().ok_or(Error::MissingIdentifier)?;
// 1. store documents ids for future deletion
for document in addition {
@ -184,7 +184,7 @@ pub fn apply_documents_partial_addition<'a, 'b>(
None => return Err(Error::SchemaMissing),
};
let identifier = schema.identifier();
let identifier = schema.identifier().ok_or(Error::MissingIdentifier)?;
// 1. store documents ids for future deletion
for mut document in addition {

View file

@ -40,7 +40,7 @@ impl DocumentsDeletion {
where
D: serde::Serialize,
{
let identifier = schema.identifier();
let identifier = schema.identifier().ok_or(Error::MissingIdentifier)?;
let document_id = match extract_document_id(&identifier, &document)? {
Some(id) => id,
None => return Err(Error::MissingDocumentId),