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

Method add

packages/graph/src/indexes/FullTextIndex.ts:55–74  ·  view source on GitHub ↗
(elementId: ElementId, value: unknown)

Source from the content-addressed store, hash-verified

53 }
54
55 public add(elementId: ElementId, value: unknown): void {
56 if (typeof value !== "string" || value.length === 0) {
57 return;
58 }
59
60 // Store the original document
61 this.#documents.set(elementId, value);
62
63 // Extract and index terms
64 const terms = extractTerms(value, this.#options);
65
66 for (const term of terms) {
67 let ids = this.#invertedIndex.get(term);
68 if (!ids) {
69 ids = new Set();
70 this.#invertedIndex.set(term, ids);
71 }
72 ids.add(elementId);
73 }
74 }
75
76 public remove(elementId: ElementId, _value: unknown): void {
77 const storedText = this.#documents.get(elementId);

Callers 1

updateMethod · 0.95

Calls 3

extractTermsFunction · 0.90
getMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected