mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
Only register the _geo field
This commit is contained in:
parent
379cedb096
commit
2f8ba6944f
@ -303,8 +303,6 @@ where
|
|||||||
{
|
{
|
||||||
// will be used in 'inject_vectors
|
// will be used in 'inject_vectors
|
||||||
let vectors_value: Box<RawValue>;
|
let vectors_value: Box<RawValue>;
|
||||||
let geo_lat: Box<RawValue>;
|
|
||||||
let geo_lng: Box<RawValue>;
|
|
||||||
|
|
||||||
document_buffer.clear();
|
document_buffer.clear();
|
||||||
let mut unordered_field_buffer = Vec::new();
|
let mut unordered_field_buffer = Vec::new();
|
||||||
@ -355,29 +353,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(geo_value) = document.geo_field()? {
|
if let Some(geo_value) = document.geo_field()? {
|
||||||
#[derive(serde::Deserialize)]
|
let fid = fields_ids_map.id_or_insert("_geo").ok_or(UserError::AttributeLimitReached)?;
|
||||||
struct Geo {
|
unordered_field_buffer.push((fid, geo_value));
|
||||||
lat: serde_json::Value,
|
|
||||||
lng: serde_json::Value,
|
|
||||||
}
|
|
||||||
|
|
||||||
// We must flatten and generate the fields ids for the geo sub fields
|
|
||||||
if let Ok(Geo { lat, lng }) = serde_json::from_str(geo_value.get()) {
|
|
||||||
let lat_id =
|
|
||||||
fields_ids_map.id_or_insert("_geo.lat").ok_or(UserError::AttributeLimitReached)?;
|
|
||||||
geo_lat = serde_json::value::to_raw_value(&lat).unwrap();
|
|
||||||
unordered_field_buffer.push((lat_id, &geo_lat));
|
|
||||||
|
|
||||||
let lng_id =
|
|
||||||
fields_ids_map.id_or_insert("_geo.lng").ok_or(UserError::AttributeLimitReached)?;
|
|
||||||
geo_lng = serde_json::value::to_raw_value(&lng).unwrap();
|
|
||||||
unordered_field_buffer.push((lng_id, &geo_lng));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_field_buffer.sort_by_key(|(fid, _)| *fid);
|
unordered_field_buffer.sort_by_key(|(fid, _)| *fid);
|
||||||
for (fid, value) in unordered_field_buffer.iter() {
|
for (fid, value) in unordered_field_buffer.iter() {
|
||||||
dbg!(fields_ids_map.name(*fid), value.get());
|
|
||||||
writer.insert(*fid, value.get().as_bytes()).unwrap();
|
writer.insert(*fid, value.get().as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user