mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-02 10:05:05 +08:00
Remove uses of UserError::MissingPrimaryKey not related to inference
This commit is contained in:
parent
a8defb585b
commit
13c95d25aa
@ -21,6 +21,10 @@ const DEFAULT_PRIMARY_KEY: &str = "id";
|
|||||||
/// - all the documents id exist and are extracted,
|
/// - all the documents id exist and are extracted,
|
||||||
/// - the validity of them but also,
|
/// - the validity of them but also,
|
||||||
/// - the validity of the `_geo` field depending on the settings.
|
/// - the validity of the `_geo` field depending on the settings.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// - if reader.is_empty(), this function may panic in some cases
|
||||||
pub fn enrich_documents_batch<R: Read + Seek>(
|
pub fn enrich_documents_batch<R: Read + Seek>(
|
||||||
rtxn: &heed::RoTxn,
|
rtxn: &heed::RoTxn,
|
||||||
index: &Index,
|
index: &Index,
|
||||||
@ -49,7 +53,7 @@ pub fn enrich_documents_batch<R: Read + Seek>(
|
|||||||
primary_key: primary_key.to_string(),
|
primary_key: primary_key.to_string(),
|
||||||
document: obkv_to_object(&first_document, &documents_batch_index)?,
|
document: obkv_to_object(&first_document, &documents_batch_index)?,
|
||||||
})),
|
})),
|
||||||
None => Ok(Err(UserError::MissingPrimaryKey)),
|
None => unreachable!("Called with reader.is_empty()"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16,7 +16,7 @@ use super::helpers::{create_sorter, create_writer, keep_latest_obkv, merge_obkvs
|
|||||||
use super::{IndexDocumentsMethod, IndexerConfig};
|
use super::{IndexDocumentsMethod, IndexerConfig};
|
||||||
use crate::documents::{DocumentsBatchIndex, EnrichedDocument, EnrichedDocumentsBatchReader};
|
use crate::documents::{DocumentsBatchIndex, EnrichedDocument, EnrichedDocumentsBatchReader};
|
||||||
use crate::error::{Error, InternalError, UserError};
|
use crate::error::{Error, InternalError, UserError};
|
||||||
use crate::index::db_name;
|
use crate::index::{db_name, main_key};
|
||||||
use crate::update::{AvailableDocumentsIds, ClearDocuments, UpdateIndexingStep};
|
use crate::update::{AvailableDocumentsIds, ClearDocuments, UpdateIndexingStep};
|
||||||
use crate::{
|
use crate::{
|
||||||
ExternalDocumentsIds, FieldDistribution, FieldId, FieldIdMapMissingEntry, FieldsIdsMap, Index,
|
ExternalDocumentsIds, FieldDistribution, FieldId, FieldIdMapMissingEntry, FieldsIdsMap, Index,
|
||||||
@ -459,7 +459,10 @@ impl<'a, 'i> Transform<'a, 'i> {
|
|||||||
let primary_key = self
|
let primary_key = self
|
||||||
.index
|
.index
|
||||||
.primary_key(wtxn)?
|
.primary_key(wtxn)?
|
||||||
.ok_or(Error::UserError(UserError::MissingPrimaryKey))?
|
.ok_or(Error::InternalError(InternalError::DatabaseMissingEntry {
|
||||||
|
db_name: db_name::MAIN,
|
||||||
|
key: Some(main_key::PRIMARY_KEY_KEY),
|
||||||
|
}))?
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let mut external_documents_ids = self.index.external_documents_ids(wtxn)?;
|
let mut external_documents_ids = self.index.external_documents_ids(wtxn)?;
|
||||||
@ -557,8 +560,14 @@ impl<'a, 'i> Transform<'a, 'i> {
|
|||||||
mut new_fields_ids_map: FieldsIdsMap,
|
mut new_fields_ids_map: FieldsIdsMap,
|
||||||
) -> Result<TransformOutput> {
|
) -> Result<TransformOutput> {
|
||||||
// There already has been a document addition, the primary key should be set by now.
|
// There already has been a document addition, the primary key should be set by now.
|
||||||
let primary_key =
|
let primary_key = self
|
||||||
self.index.primary_key(wtxn)?.ok_or(UserError::MissingPrimaryKey)?.to_string();
|
.index
|
||||||
|
.primary_key(wtxn)?
|
||||||
|
.ok_or(InternalError::DatabaseMissingEntry {
|
||||||
|
db_name: db_name::MAIN,
|
||||||
|
key: Some(main_key::PRIMARY_KEY_KEY),
|
||||||
|
})?
|
||||||
|
.to_string();
|
||||||
let field_distribution = self.index.field_distribution(wtxn)?;
|
let field_distribution = self.index.field_distribution(wtxn)?;
|
||||||
|
|
||||||
// Delete the soft deleted document ids from the maps inside the external_document_ids structure
|
// Delete the soft deleted document ids from the maps inside the external_document_ids structure
|
||||||
|
Loading…
Reference in New Issue
Block a user