ITADN

HybridSearch.search() crashes with AttributeError for any VectorStore backend other than inmemory

#833OpenKaifAhmad1 创建于 24 天前
bughelp wantedeasy-fix
K
KaifAhmad1commented
## Summary `HybridSearch.search()` directly accesses `self.vector_store.vectors`, a dict that `VectorStore.__init__` only creates when `backend="inmemory"`. For every other backend `VectorStore` supports (`faiss`, `weaviate`, `qdrant`, `milvus`, `pinecone`, `pgvector`, `sqlite`), that attribute is never set, so `HybridSearch.search()` raises `AttributeError: 'VectorStore' object has no attribute 'vectors'`. This is caught internally and reported as a failure to Semantica's progress tracker, but it means `HybridSearch` is effectively unusable with any real/production backend and only works against the in-memory demo store. This is the same root issue previously observed surfacing through `AgentContext.find_precedents_advanced()`, which logs `"Vector store search failed, falling back to graph search: 'VectorStore' object has no attribute 'vectors'"` and silently falls back to graph search instead of raising — same underlying assumption, different call site. ## Steps to Reproduce ```python from semantica.vector_store import VectorStore, HybridSearch vs = VectorStore(backend="faiss", dimension=384) vs.store_vectors(vectors=[[0.1] * 384], metadata=[{"content": "example"}]) hs = HybridSearch(vector_store=vs, graph_store=None) hs.search(query="example", query_vector=[0.1] * 384) ``` ## Expected Behavior `HybridSearch.search()` should work against any backend `VectorStore` supports, not just `backend="inmemory"`, since nothing in `VectorStore`'s public API documents `.vectors` as a stable attribute for non-inmemory backends. ## Actual Behavior ``` AttributeError: 'VectorStore' object has no attribute 'vectors' ``` ## Root Cause In `semantica/vector_store/hybrid_search.py`, around line 314: ```python vector_ids = list(self.vector_store.vectors.keys()) vectors = [self.vector_store.vectors[vid] for vid in vector_ids] ``` `self.vectors` is only initialized in `VectorStore.__init__` inside the `if self.backend == "inmemory":` branch (`semantica/vector_store/vector_store.py`, around line 118-124). Any other backend routes through `self._backend_store` instead and never gets a `.vectors` dict on the `VectorStore` instance itself. ## Suggested Fix Direction `HybridSearch` should retrieve candidate vectors through `VectorStore`'s public, backend-agnostic API (e.g. `search_vectors()` / `search()`) rather than reaching into `.vectors` directly, so it works uniformly across all supported backends. ## Environment - semantica: `0.6.0` - Python: `3.12.10` - OS: Windows 11
0 条评论