MCPcopy Index your code
hub / github.com/coder/coder / Search

Method Search

agent/filefinder/engine.go:190–216  ·  view source on GitHub ↗

Search performs a fuzzy file search across all roots.

(_ context.Context, query string, opts SearchOptions)

Source from the content-addressed store, hash-verified

188
189// Search performs a fuzzy file search across all roots.
190func (e *Engine) Search(_ context.Context, query string, opts SearchOptions) ([]Result, error) {
191 if e.closed.Load() {
192 return nil, ErrClosed
193 }
194 snapPtr := e.snap.Load()
195 if snapPtr == nil || len(*snapPtr) == 0 {
196 return nil, nil
197 }
198 roots := *snapPtr
199 plan := newQueryPlan(query)
200 if len(plan.Normalized) == 0 {
201 return nil, nil
202 }
203 if opts.Limit <= 0 {
204 opts.Limit = 100
205 }
206 if opts.MaxCandidates <= 0 {
207 opts.MaxCandidates = 10000
208 }
209 params := defaultScoreParams()
210 var allCands []candidate
211 for _, rs := range roots {
212 allCands = append(allCands, searchSnapshot(plan, rs.snap, opts.MaxCandidates)...)
213 }
214 results := mergeAndScore(allCands, plan, params, opts.Limit)
215 return results, nil
216}
217
218// Close shuts down the engine.
219func (e *Engine) Close() error {

Calls 5

newQueryPlanFunction · 0.85
defaultScoreParamsFunction · 0.85
searchSnapshotFunction · 0.85
mergeAndScoreFunction · 0.85
LoadMethod · 0.45