mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Merge #3515
3515: Consider null as a valid geo field r=irevoire a=irevoire Fix #3497 Associated spec; https://github.com/meilisearch/specifications/pull/222 Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
a8f6f108e0
@ -1027,6 +1027,53 @@ async fn error_document_field_limit_reached() {
|
|||||||
@"");
|
@"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[actix_rt::test]
|
||||||
|
async fn add_documents_with_geo_field() {
|
||||||
|
let server = Server::new().await;
|
||||||
|
let index = server.index("doggo");
|
||||||
|
index.update_settings(json!({"sortableAttributes": ["_geo"]})).await;
|
||||||
|
|
||||||
|
let documents = json!([
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"_geo": null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3",
|
||||||
|
"_geo": { "lat": 1, "lng": 1 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "4",
|
||||||
|
"_geo": { "lat": "1", "lng": "1" },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
index.add_documents(documents, None).await;
|
||||||
|
let response = index.wait_task(1).await;
|
||||||
|
snapshot!(json_string!(response, { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }),
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
|
"uid": 1,
|
||||||
|
"indexUid": "doggo",
|
||||||
|
"status": "succeeded",
|
||||||
|
"type": "documentAdditionOrUpdate",
|
||||||
|
"canceledBy": null,
|
||||||
|
"details": {
|
||||||
|
"receivedDocuments": 4,
|
||||||
|
"indexedDocuments": 4
|
||||||
|
},
|
||||||
|
"error": null,
|
||||||
|
"duration": "[duration]",
|
||||||
|
"enqueuedAt": "[date]",
|
||||||
|
"startedAt": "[date]",
|
||||||
|
"finishedAt": "[date]"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn add_documents_invalid_geo_field() {
|
async fn add_documents_invalid_geo_field() {
|
||||||
let server = Server::new().await;
|
let server = Server::new().await;
|
||||||
|
@ -395,6 +395,7 @@ pub fn validate_geo_from_json(id: &DocumentId, bytes: &[u8]) -> Result<StdResult
|
|||||||
(Some(_), None) => Ok(Err(MissingLongitude { document_id: debug_id() })),
|
(Some(_), None) => Ok(Err(MissingLongitude { document_id: debug_id() })),
|
||||||
(None, None) => Ok(Err(MissingLatitudeAndLongitude { document_id: debug_id() })),
|
(None, None) => Ok(Err(MissingLatitudeAndLongitude { document_id: debug_id() })),
|
||||||
},
|
},
|
||||||
|
Value::Null => Ok(Ok(())),
|
||||||
value => Ok(Err(NotAnObject { document_id: debug_id(), value })),
|
value => Ok(Err(NotAnObject { document_id: debug_id(), value })),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ pub fn extract_geo_points<R: io::Read + io::Seek>(
|
|||||||
} else if lat.is_some() && lng.is_none() {
|
} else if lat.is_some() && lng.is_none() {
|
||||||
return Err(GeoError::MissingLongitude { document_id: document_id() })?;
|
return Err(GeoError::MissingLongitude { document_id: document_id() })?;
|
||||||
}
|
}
|
||||||
|
// else => the _geo object was `null`, there is nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
writer_into_reader(writer)
|
writer_into_reader(writer)
|
||||||
|
Loading…
Reference in New Issue
Block a user