Skip to main content

nusy_graph_query/
lib.rs

1//! # nusy-graph-query
2//!
3//! Graph-native semantic search for Arrow RecordBatches — embeddings,
4//! traversal, hybrid ranking, and caching.
5//!
6//! This crate provides the building blocks for combining structural graph
7//! queries with semantic similarity search over Apache Arrow data.
8//!
9//! ## Quick Example
10//!
11//! ```rust
12//! use nusy_graph_query::{HashEmbeddingProvider, EmbeddingProvider, cosine_similarity};
13//!
14//! let provider = HashEmbeddingProvider::new(384);
15//! let vecs = provider.embed_batch(&[
16//!     "Alice knows Bob".to_string(),
17//!     "Cat is an animal".to_string(),
18//! ]).unwrap();
19//!
20//! let sim = cosine_similarity(&vecs[0], &vecs[1]);
21//! assert!(sim >= -1.0 && sim <= 1.0);
22//! ```
23//!
24//! ## Modules
25//!
26//! - [`embedding`] — `EmbeddingProvider` trait, hash provider, cosine similarity
27//! - [`traversal`] — Generic BFS/DFS over Arrow edge RecordBatches
28//! - [`hybrid_rank`] — Combine structural + semantic scores
29//! - [`cache`] — Content-hash embedding cache with Parquet persistence
30//! - [`subprocess`] — Python sentence-transformers provider (feature: `subprocess`)
31//! - [`fastembed_provider`] — Local ONNX embedding provider (feature: `fastembed`)
32//!
33//! ## Feature Flags
34//!
35//! | Flag | Description |
36//! |------|-------------|
37//! | `subprocess` | Enable Python sentence-transformers provider |
38//! | `fastembed` | Enable local ONNX embedding via fastembed-rs (~2ms/chunk) |
39
40pub mod cache;
41pub mod embedding;
42#[cfg(feature = "fastembed")]
43pub mod fastembed_provider;
44pub mod hybrid_rank;
45#[cfg(feature = "subprocess")]
46pub mod subprocess;
47pub mod traversal;
48
49// Re-export key types at crate root for convenience.
50pub use cache::EmbeddingCache;
51pub use embedding::{
52    EmbeddedItem, EmbeddingError, EmbeddingProvider, HashEmbeddingProvider, SearchResult,
53    cosine_similarity, hash_to_vector, semantic_search,
54};
55#[cfg(feature = "fastembed")]
56pub use fastembed_provider::FastembedProvider;
57pub use hybrid_rank::{HybridConfig, RankCandidate, RankedResult, hybrid_rank};
58#[cfg(feature = "subprocess")]
59pub use subprocess::SubprocessEmbeddingProvider;
60pub use traversal::{
61    Direction, EdgeSchema, TraversalNode, bfs, bfs_with_adjacency, build_adjacency,
62    build_adjacency_from_list,
63};