MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / searchNodes

Function searchNodes

packages/agentflow/src/features/node-palette/search.ts:88–110  ·  view source on GitHub ↗
(nodes: NodeDataSchema[], searchValue: string)

Source from the content-addressed store, hash-verified

86 * Score and sort nodes by fuzzy search relevance
87 */
88export function searchNodes(nodes: NodeDataSchema[], searchValue: string): NodeDataSchema[] {
89 // Return all nodes unsorted if search is empty
90 if (!searchValue || searchValue.trim() === '') {
91 return nodes
92 }
93
94 // Calculate fuzzy scores for each node
95 const nodesWithScores = nodes.map((nd) => {
96 const nameScore = fuzzyScore(searchValue, nd.name)
97 const labelScore = fuzzyScore(searchValue, nd.label)
98 const categoryScore = fuzzyScore(searchValue, nd.category || '') * 0.5 // Lower weight for category
99 const descriptionScore = fuzzyScore(searchValue, nd.description || '') * 0.3 // Even lower for description
100 const maxScore = Math.max(nameScore, labelScore, categoryScore, descriptionScore)
101
102 return { node: nd, score: maxScore }
103 })
104
105 // Filter nodes with score > 0 and sort by score (highest first)
106 return nodesWithScores
107 .filter((item) => item.score > 0)
108 .sort((a, b) => b.score - a.score)
109 .map((item) => item.node)
110}
111
112/**
113 * Debounce function for search input

Callers 2

search.test.tsFile · 0.90
AddNodesDrawerComponentFunction · 0.90

Calls 1

fuzzyScoreFunction · 0.70

Tested by

no test coverage detected