Graph expansion
Graph neighbor search · Multi-hop expansion
Adding retrieval candidates by walking a knowledge graph outward, a fixed number of hops, from the entities a query mentions.
In DocSlurpGlossary entry
On this page
Graph expansion adds candidates to a search by following a knowledge graph. Find the entities the query names, walk their edges one or more hops, and return the passages that mention any entity you reached.
Search for “London office”. Keyword and vector search return passages that talk about the London office. The graph also holds London office → launch led by → CFO (from launch-review.pdf) and CFO → pre-approves → Learjet charters (from travel-desk-guide.pdf). Two hops from London office reach Learjet charters, so charter-agreement.pdf p. 3, “The Learjet 75 is ready for wheels-up within three hours of the assistant’s request,” joins the candidates. It never mentions London, but it says how fast the launch team can get there.
In DocSlurp
With graphExpansion on (the default when a project builds a graph), search does two things:
- Neighbor search. It matches the query against entity names by full text and keeps up to 8 seeds, walks
graphHopsedges in either direction (1 to 3; the default is 2 with GraphRAG, else 1), and ranks chunks that mention reached entities by mention count (graphNeighborSearchincore/server/src/services/search.ts). That list joins the keyword and vector lists before fusion. - Query terms. It appends up to 4 entity names found in matching chunks to the keyword query (
core/server/src/search/graph-expansion.ts).
Seeds use Postgres full-text matching, which requires every query term to appear in one entity name. Short, entity-like queries (“London office”) seed well; a full question (“who approves the jet for the London launch?”) usually matches no single name, and neighbor search returns nothing.
The gotcha
Each hop multiplies the neighborhood. A hub entity like the company name connects to everything, and two hops from it is most of the corpus. Expansion works best at one or two hops, with fusion and a reranker to push the drift back down.
In DocSlurp
In DocSlurp
With graphExpansion on, search matches up to 8 entity names against the query, walks graphHops edges (1 to 3), and returns chunks that mention the reached entities as one more list for fusion (graphNeighborSearch in core/server/src/services/search.ts). It also appends up to 4 matching entity names to the keyword query (core/server/src/search/graph-expansion.ts).