feat(search): full-text, vector, hybrid search and auto-link suggestions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-10-21 03:39:20 +02:00
1 parent fbcfcf678f
commit e1e64ca2de
11 files changed
+3372 -5

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
//! Deterministic fake embedder for tests, examples and benchmarks.
use synapse_core::embed::{EmbedError, Embedder};
/// Bag-of-words hashing embedder: texts sharing words get a high cosine similarity.
pub struct HashEmbedder {
dims: usize,
model: String,
}
impl HashEmbedder {
pub fn new(dims: usize) -> Self {
Self::with_model(dims, "test/hash")
}
pub fn with_model(dims: usize, model: &str) -> Self {
Self {
dims,
model: model.to_string(),
}
}
pub fn embed_one(&self, text: &str) -> Vec<f32> {
let mut v = vec![0f32; self.dims];
for word in text
.split(|c: char| !c.is_alphanumeric())
.filter(|w| !w.is_empty())
{
// FNV-1a over the lowercased word.
let mut h: u64 = 0xcbf29ce484222325;
for b in word.to_lowercase().bytes() {
h = (h ^ b as u64).wrapping_mul(0x100000001b3);
}
v[(h % self.dims as u64) as usize] += 1.0;
}
v
}
}
impl Embedder for HashEmbedder {
fn model_id(&self) -> String {
self.model.clone()
}
fn dims(&self) -> usize {
self.dims
}
fn embed(&self, texts: &[String]) -> Result<Vec<Vec<f32>>, EmbedError> {
Ok(texts.iter().map(|t| self.embed_one(t)).collect())
}
}