mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-03-20 06:30:38 +01:00
Searching for a document that does not exist no longer raises an error
This commit is contained in:
parent
7df5e3f059
commit
60ff1b19a8
@ -384,7 +384,6 @@ UnsupportedMediaType , InvalidRequest , UNSUPPORTED_MEDIA
|
|||||||
// Experimental features
|
// Experimental features
|
||||||
VectorEmbeddingError , InvalidRequest , BAD_REQUEST ;
|
VectorEmbeddingError , InvalidRequest , BAD_REQUEST ;
|
||||||
NotFoundSimilarId , InvalidRequest , BAD_REQUEST ;
|
NotFoundSimilarId , InvalidRequest , BAD_REQUEST ;
|
||||||
NotFoundDocumentId , InvalidRequest , BAD_REQUEST ;
|
|
||||||
InvalidDocumentEditionContext , InvalidRequest , BAD_REQUEST ;
|
InvalidDocumentEditionContext , InvalidRequest , BAD_REQUEST ;
|
||||||
InvalidDocumentEditionFunctionFilter , InvalidRequest , BAD_REQUEST ;
|
InvalidDocumentEditionFunctionFilter , InvalidRequest , BAD_REQUEST ;
|
||||||
EditDocumentsByFunctionError , 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 mut candidates = if let Some(ids) = ids {
|
||||||
let external_document_ids = index.external_documents_ids();
|
let external_document_ids = index.external_documents_ids();
|
||||||
let mut candidates = RoaringBitmap::new();
|
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 Some(docid) = external_document_ids.get(&rtxn, id)? else {
|
||||||
let error = MeilisearchHttpError::DocumentNotFound(id.clone().into_inner());
|
continue;
|
||||||
let msg = format!("In `.ids[{index}]`: {error}");
|
|
||||||
return Err(ResponseError::from_msg(msg, Code::NotFoundDocumentId));
|
|
||||||
};
|
};
|
||||||
candidates.insert(docid);
|
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 (response, code) = index.fetch_documents(json!({"ids": ["0", 3, 42] })).await;
|
||||||
let (response2, code2) = index.get_all_documents_raw("?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###"
|
snapshot!(json_string!(response, { ".enqueuedAt" => "[date]" }), @r###"
|
||||||
{
|
{
|
||||||
"message": "In `.ids[2]`: Document `42` not found.",
|
"results": [
|
||||||
"code": "not_found_document_id",
|
{
|
||||||
"type": "invalid_request",
|
"id": 0,
|
||||||
"link": "https://docs.meilisearch.com/errors#not_found_document_id"
|
"color": "red"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"offset": 0,
|
||||||
|
"limit": 20,
|
||||||
|
"total": 2
|
||||||
}
|
}
|
||||||
"###);
|
"###);
|
||||||
assert_eq!(code, code2);
|
assert_eq!(code, code2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user