From 16a99aa95ea86d8388ef3e40dee3dbb6aced1c82 Mon Sep 17 00:00:00 2001 From: qdequele Date: Thu, 5 Mar 2020 15:49:47 +0100 Subject: [PATCH] update to infer identifier; fix #498 --- meilisearch-http/src/routes/document.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/meilisearch-http/src/routes/document.rs b/meilisearch-http/src/routes/document.rs index e0ab4e88d..c1745d78f 100644 --- a/meilisearch-http/src/routes/document.rs +++ b/meilisearch-http/src/routes/document.rs @@ -1,7 +1,7 @@ use std::collections::{BTreeSet, HashSet}; use indexmap::IndexMap; -use meilisearch_core::settings::{SettingsUpdate, UpdateState}; +use meilisearch_schema::Schema; use serde::{Deserialize, Serialize}; use serde_json::Value; use tide::{Request, Response}; @@ -135,7 +135,7 @@ async fn update_multiple_documents(mut ctx: Request, is_partial: bool) -> let db = &ctx.state().db; let reader = db.main_read_txn()?; - let mut update_writer = db.update_write_txn()?; + let current_schema = index.main.schema(&reader)?; if current_schema.is_none() { let id = match query.identifier { @@ -145,11 +145,9 @@ async fn update_multiple_documents(mut ctx: Request, is_partial: bool) -> None => return Err(ResponseError::bad_request("Could not infer a schema")), }, }; - let settings_update = SettingsUpdate { - identifier: UpdateState::Update(id), - ..SettingsUpdate::default() - }; - index.settings_update(&mut update_writer, settings_update)?; + let mut writer = db.main_write_txn()?; + index.main.put_schema(&mut writer, &Schema::with_identifier(&id))?; + writer.commit()?; } let mut document_addition = if is_partial { @@ -162,6 +160,7 @@ async fn update_multiple_documents(mut ctx: Request, is_partial: bool) -> document_addition.update_document(document); } + let mut update_writer = db.update_write_txn()?; let update_id = document_addition.finalize(&mut update_writer)?; update_writer.commit()?;