create a new database containing all the documents that were geo-faceted

This commit is contained in:
Irevoire 2021-08-26 17:49:50 +02:00 committed by Tamo
parent 4b459768a0
commit ea2f2ecf96
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
4 changed files with 70 additions and 3 deletions

View file

@ -182,6 +182,8 @@ pub(crate) fn write_typed_chunk_into_index(
TypedChunk::GeoPoints(mut geo_points) => {
// TODO: TAMO: we should create the rtree with the `RTree::bulk_load` function
let mut rtree = index.geo_rtree(wtxn)?.unwrap_or_default();
let mut doc_ids = index.geo_faceted_documents_ids(wtxn)?;
while let Some((key, value)) = geo_points.next()? {
// convert the key back to a u32 (4 bytes)
let (key, _) = helpers::try_split_array_at::<u8, 4>(key).unwrap();
@ -192,8 +194,10 @@ pub(crate) fn write_typed_chunk_into_index(
let (lng, _) = helpers::try_split_array_at::<u8, 8>(tail).unwrap();
let point = [f64::from_ne_bytes(lat), f64::from_ne_bytes(lng)];
rtree.insert(GeoPoint::new(point, key));
doc_ids.insert(key);
}
index.put_geo_rtree(wtxn, &rtree)?;
index.put_geo_faceted_documents_ids(wtxn, &doc_ids)?;
}
}