Skip to main content

Module hybrid

Module hybrid 

Source
Expand description

Hybrid spatial-vector search: spatial R-tree as a pre-filter for HNSW vector search.

Query pattern:

SELECT * FROM restaurants
WHERE ST_DWithin(location, geo_point(-73.98, 40.75), 500)
ORDER BY vector_distance(embedding, $query_vec) LIMIT 10

Pipeline:

  1. R-tree range search → candidate entry IDs
  2. Convert entry IDs to RoaringBitmap
  3. Pass bitmap into vector search as pre-filter
  4. HNSW traversal skips entries not in bitmap

This is a unique NodeDB differentiator — PostGIS + pgvector can’t do this in a single index scan.

Structs§

SpatialPreFilterResult
Result of the spatial pre-filter phase.

Functions§

bitmap_contains
Check if an entry ID is set in a bitmap.
ids_to_bitmap
Convert candidate entry IDs to a packed bitmap suitable for vector engine pre-filtering.
spatial_prefilter
Execute the spatial pre-filter phase.