mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	Searching for a document that does not exist no longer raises an error
This commit is contained in:
		| @@ -384,7 +384,6 @@ UnsupportedMediaType                  , InvalidRequest       , UNSUPPORTED_MEDIA | ||||
| // Experimental features | ||||
| VectorEmbeddingError                  , InvalidRequest       , BAD_REQUEST ; | ||||
| NotFoundSimilarId                     , InvalidRequest       , BAD_REQUEST ; | ||||
| NotFoundDocumentId                    , InvalidRequest       , BAD_REQUEST ; | ||||
| InvalidDocumentEditionContext         , InvalidRequest       , BAD_REQUEST ; | ||||
| InvalidDocumentEditionFunctionFilter  , InvalidRequest       , BAD_REQUEST ; | ||||
| EditDocumentsByFunctionError          , InvalidRequest       , BAD_REQUEST | ||||
|   | ||||
| @@ -1513,11 +1513,9 @@ fn retrieve_documents<S: AsRef<str>>( | ||||
|     let mut candidates = if let Some(ids) = ids { | ||||
|         let external_document_ids = index.external_documents_ids(); | ||||
|         let mut candidates = RoaringBitmap::new(); | ||||
|         for (index, id) in ids.iter().enumerate() { | ||||
|         for id in ids.iter() { | ||||
|             let Some(docid) = external_document_ids.get(&rtxn, id)? else { | ||||
|                 let error = MeilisearchHttpError::DocumentNotFound(id.clone().into_inner()); | ||||
|                 let msg = format!("In `.ids[{index}]`: {error}"); | ||||
|                 return Err(ResponseError::from_msg(msg, Code::NotFoundDocumentId)); | ||||
|                 continue; | ||||
|             }; | ||||
|             candidates.insert(docid); | ||||
|         } | ||||
|   | ||||
| @@ -687,13 +687,23 @@ async fn get_document_not_found_ids() { | ||||
|  | ||||
|     let (response, code) = index.fetch_documents(json!({"ids": ["0", 3, 42] })).await; | ||||
|     let (response2, code2) = index.get_all_documents_raw("?ids=0,3,42").await; | ||||
|     snapshot!(code, @"400 Bad Request"); | ||||
|     // the document with id 42 is not in the results since it doesn't exist | ||||
|     // however, no error is raised | ||||
|     snapshot!(code, @"200 OK"); | ||||
|     snapshot!(json_string!(response, { ".enqueuedAt" => "[date]" }), @r###" | ||||
|     { | ||||
|       "message": "In `.ids[2]`: Document `42` not found.", | ||||
|       "code": "not_found_document_id", | ||||
|       "type": "invalid_request", | ||||
|       "link": "https://docs.meilisearch.com/errors#not_found_document_id" | ||||
|       "results": [ | ||||
|         { | ||||
|           "id": 0, | ||||
|           "color": "red" | ||||
|         }, | ||||
|         { | ||||
|           "id": 3 | ||||
|         } | ||||
|       ], | ||||
|       "offset": 0, | ||||
|       "limit": 20, | ||||
|       "total": 2 | ||||
|     } | ||||
|     "###); | ||||
|     assert_eq!(code, code2); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user