Repository navigation
Description
Part of #4859.
Motivation
vector.fuse already fuses vector + full-text scores server-side (RRF/DBSF/LINEAR), but there is no single expression that also expands over graph relationships (out()/shortestPath()) before or after fusion — that requires orchestrating multiple statements, which is error-prone and unsafe for a model to hand-write (risk of unbounded traversal, missing dedup). Justification: primarily #2 unreachable-as-a-single-call orchestration, secondarily #1 ergonomic guardrail for vector.fuse syntax.
Proposed design
- Tool name:
hybrid_search - Input schema:
{
"type": "object",
"properties": {
"database": {"type": "string"},
"vectorIndexName": {"type": "string"},
"queryVector": {"type": "array", "items": {"type": "number"}},
"k": {"type": "integer", "default": 10},
"expand": {
"type": "object",
"properties": {
"edgeTypes": {"type": "array", "items": {"type": "string"}},
"direction": {"type": "string", "enum": ["out", "in", "both"], "default": "out"},
"maxDepth": {"type": "integer", "default": 1, "maximum": 3}
}
},
"fulltextIndexName": {"type": "string"},
"fulltextQuery": {"type": "string"},
"fusionStrategy": {"type": "string", "enum": ["RRF", "DBSF", "LINEAR"], "default": "RRF"}
},
"required": ["database", "vectorIndexName", "queryVector", "k"]
}- Output:
{results: [{rid, fusedScore, path?, properties}]} maxDepthis capped server-side (hard max, e.g. 3) to prevent runaway traversal — this is the specific unsafe-if-hand-written behavior the tool guards against.- Permission gating:
allowReadsonly (read-only pipeline). - Engine functions used:
SQLFunctionVectorNeighbors/SQLFunctionVectorSparseNeighbors,SQLFunctionOut/SQLFunctionOutE(function/sql/graph/),SQLFunctionSearchIndex(fulltext.searchIndex),SQLFunctionVectorFuse.
Acceptance criteria
- Depth-limited traversal enforced server-side regardless of client-supplied
maxDepth. - Works with vector-only input (no
fulltextQuery) and with vector+fulltext+expand combined. - Dedup of nodes reached via multiple paths before fusion scoring.
- Registered in both transports; permission-gated on
allowReads. - Tests cover: vector-only, vector+expand, vector+expand+fulltext fusion, depth-cap enforcement.
- Docs include a worked example query and note that
vector.fusealone (viaquerytool) remains available for pure two-way fusion without graph expansion.
Files to touch
server/src/main/java/com/arcadedb/server/mcp/tools/HybridSearchTool.java (new), MCPHttpHandler.java, MCPStdioServer.java, tests, docs.
Dependencies
Blocked-by #4860 (vector_search) for shared vector-leg validation logic. Related to the full_text_search tool issue — the fulltext leg here calls SEARCH_INDEX directly and does not require that tool to exist, but the two should share terminology/docs.
Effort estimate
L — most orchestration surface, most edge cases (cycles, dedup, depth caps, three-way scoring).
Activity
robfrank commentedon Jul 14, 2026
Blocked by #5267 (or at least: #5267 should be a conscious decision before this starts).
ArcadeDB's full-text BM25 is scored per bucket (document frequency is bucket-scoped, average document length is type-wide - the engine documents this at
LSMTreeFullTextIndex.java:547). Merging hits across buckets and ranking them globally therefore compares scores normalized against different corpora.This matters specifically for
hybrid_search, because fusing per-bucket-scoped BM25 scores with vector similarity scores bakes that unsoundness into a second surface, where it is much harder to unwind than it is today. Today it is confined to relevance ordering; after fusion it would silently distort the fused ranking itself.Surfaced while building #4862 (PR #5263), where a less relevant document outranked a more relevant one until the test fixture forced
BUCKETS 1. It is pre-existing (SQL'sORDER BY $score DESChas the identical exposure) and was explicitly not a blocker for #4862, but it is a live design input for this issue.Worth settling #5267's direction - type-wide corpus statistics, a global re-scoring pass, or an explicit best-effort contract - before the fusion strategy here is fixed.
fix(#4861): report the full-text index unfused, and stop probing for …
refactor(#4861): drop the unused expansion probe row
fix(#4861): report the seed budget and reject non-numeric weights
fix(#4861): reject a weight for a leg the request does not use
docs(#4861): mark the SQL trust boundary and the empty-leg weight case
feat(#4861): add the MCP hybrid_search tool (#5500)
docs(#4861): link the filed engine defect and drop the drafted issue …
feat(#4861): add the MCP hybrid_search tool (#5500)