mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-26 05:26:27 +00:00 
			
		
		
		
	Implement the SettingsAndDocumentImport batch operation
This commit is contained in:
		
				
					committed by
					
						 Clément Renault
						Clément Renault
					
				
			
			
				
	
			
			
			
						parent
						
							f68906f5dc
						
					
				
				
					commit
					07286fcc79
				
			| @@ -414,11 +414,53 @@ impl IndexScheduler { | |||||||
|                 primary_key, |                 primary_key, | ||||||
|                 method, |                 method, | ||||||
|                 content_files, |                 content_files, | ||||||
|                 document_import_tasks, |                 mut document_import_tasks, | ||||||
|                 settings: _, |                 settings, | ||||||
|                 settings_tasks: _, |                 mut settings_tasks, | ||||||
|             } => { |             } => { | ||||||
|                 todo!(); |                 // we NEED a write transaction for the index creation. | ||||||
|  |                 // To avoid blocking the whole process we're going to commit asap. | ||||||
|  |                 let mut wtxn = self.env.write_txn()?; | ||||||
|  |                 let index = self.index_mapper.create_index(&mut wtxn, &index_uid)?; | ||||||
|  |                 wtxn.commit()?; | ||||||
|  |  | ||||||
|  |                 // TODO merge the settings to only do a reindexation once. | ||||||
|  |                 for (task, (_, settings)) in settings_tasks.iter_mut().zip(settings) { | ||||||
|  |                     let checked_settings = settings.clone().check(); | ||||||
|  |                     task.details = Some(Details::Settings { settings }); | ||||||
|  |                     if let Err(error) = index.update_settings(&checked_settings) { | ||||||
|  |                         task.error = Some(error.into()); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 // TODO we must use the same write transaction, here! | ||||||
|  |  | ||||||
|  |                 let ret = index.update_documents( | ||||||
|  |                     method, | ||||||
|  |                     primary_key, | ||||||
|  |                     self.file_store.clone(), | ||||||
|  |                     content_files, | ||||||
|  |                 )?; | ||||||
|  |  | ||||||
|  |                 for (task, ret) in document_import_tasks.iter_mut().zip(ret) { | ||||||
|  |                     match ret { | ||||||
|  |                         Ok(DocumentAdditionResult { | ||||||
|  |                             indexed_documents, | ||||||
|  |                             number_of_documents, | ||||||
|  |                         }) => { | ||||||
|  |                             task.details = Some(Details::DocumentAddition { | ||||||
|  |                                 received_documents: number_of_documents, | ||||||
|  |                                 indexed_documents, | ||||||
|  |                             }); | ||||||
|  |                         } | ||||||
|  |                         Err(error) => task.error = Some(error.into()), | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 let mut tasks = settings_tasks; | ||||||
|  |                 tasks.append(&mut document_import_tasks); | ||||||
|  |  | ||||||
|  |                 Ok(tasks) | ||||||
|             } |             } | ||||||
|             Batch::DocumentDeletion { |             Batch::DocumentDeletion { | ||||||
|                 index_uid, |                 index_uid, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user