Cookbook · Reading
Fuzzy match across every node. Cheap, returns ranked hits.
Recipe
import { UPGClient } from '@unified-product-graph/sdk'
const upg = new UPGClient({ file: './product.upg' })
const hits = await upg.search('dark mode', { limit: 5 })
for (const hit of hits) {
console.log(
hit.score.toFixed(2),
hit.node.type.padEnd(12),
hit.node.title,
)
}What it does
search() does fuzzy matching against title and description, returning hits ranked by score. Pass { limit } to cap results. Score is 0–1; treat anything above ~0.4 as a real match and prune the rest.
Variations
Filter to a single type before scoring
const hits = await upg.search('dark mode', { limit: 10 })
const features = hits.filter(h => h.node.type === 'feature')See also