pub struct GeohashIndex {
pub collection: String,
pub field: String,
pub precision: u8,
/* private fields */
}Expand description
Per-collection geohash index.
Maintains a mapping of document ID → geohash string for all Point geometries in a collection. Non-Point geometries are silently skipped (geohash only works for points in v1).
Fields§
§collection: StringCollection name.
field: StringGeometry field name.
precision: u8Geohash precision (1-12).
Implementations§
Source§impl GeohashIndex
impl GeohashIndex
pub fn new(collection: &str, field: &str, precision: u8) -> Self
Sourcepub fn index_document(
&mut self,
doc_id: &str,
geometry: &Geometry,
) -> Option<String>
pub fn index_document( &mut self, doc_id: &str, geometry: &Geometry, ) -> Option<String>
Index a geometry. Only Point geometries are indexed; others are skipped. Returns the geohash string if indexed, None if skipped.
Sourcepub fn remove_document(&mut self, doc_id: &str)
pub fn remove_document(&mut self, doc_id: &str)
Remove a document from the geohash index.
Sourcepub fn prefix_search(&self, prefix: &str) -> Vec<&str>
pub fn prefix_search(&self, prefix: &str) -> Vec<&str>
Find all document IDs whose geohash matches the given prefix.
This is the core operation: a geohash prefix of length N matches all points within a cell of size determined by N. Shorter prefix = larger area.
Sourcepub fn nearby_search(
&self,
lng: f64,
lat: f64,
search_precision: Option<u8>,
) -> Vec<&str>
pub fn nearby_search( &self, lng: f64, lat: f64, search_precision: Option<u8>, ) -> Vec<&str>
Find all document IDs near a point, using geohash prefix matching.
Computes the geohash of the query point and its 8 neighbors, then collects all documents in those cells. This gives approximate results — the caller should apply exact distance filtering afterward.
search_precision controls the cell size: lower = larger area, more
results but less precise. Default: same as index precision.
Sourcepub fn get_geohash(&self, doc_id: &str) -> Option<&str>
pub fn get_geohash(&self, doc_id: &str) -> Option<&str>
Get the geohash for a specific document.
Sourcepub fn checkpoint_to_bytes(&self) -> Result<Vec<u8>, RTreeCheckpointError>
pub fn checkpoint_to_bytes(&self) -> Result<Vec<u8>, RTreeCheckpointError>
Checkpoint: serialize all entries for persistence.
Sourcepub fn from_checkpoint(bytes: &[u8]) -> Result<Self, RTreeCheckpointError>
pub fn from_checkpoint(bytes: &[u8]) -> Result<Self, RTreeCheckpointError>
Restore from checkpoint.
Auto Trait Implementations§
impl Freeze for GeohashIndex
impl RefUnwindSafe for GeohashIndex
impl Send for GeohashIndex
impl Sync for GeohashIndex
impl Unpin for GeohashIndex
impl UnsafeUnpin for GeohashIndex
impl UnwindSafe for GeohashIndex
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.