MCPcopy Create free account
hub / github.com/codemix/graph / searchPrefix

Method searchPrefix

packages/graph/src/indexes/FullTextIndex.ts:199–215  ·  view source on GitHub ↗

* Find documents where the text starts with the given prefix. * No relevance scoring - returns all matches. * * @param prefix The prefix to search for. * @returns Set of element IDs starting with the prefix.

(prefix: string)

Source from the content-addressed store, hash-verified

197 * @returns Set of element IDs starting with the prefix.
198 */
199 public searchPrefix(prefix: string): Set<ElementId> {
200 const result = new Set<ElementId>();
201
202 if (!prefix || prefix.length === 0) {
203 return result;
204 }
205
206 const normalizedPrefix = prefix.toLowerCase();
207
208 for (const [elementId, text] of this.#documents) {
209 if (text.toLowerCase().startsWith(normalizedPrefix)) {
210 result.add(elementId);
211 }
212 }
213
214 return result;
215 }
216
217 /**
218 * Find documents where any indexed term starts with the given prefix.

Callers 1

indexes.test.tsFile · 0.80

Calls 2

addMethod · 0.65
startsWithMethod · 0.45

Tested by

no test coverage detected