MCPcopy Create free account
hub / github.com/chokcoco/iCSS / loadSearchIndex

Method loadSearchIndex

MCP/server.js:98–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96 }
97
98 loadSearchIndex() {
99 debugLog('🔍 Loading search index...');
100
101 this.db.all('SELECT * FROM issues', (err, rows) => {
102 if (err) {
103 console.error('❌ Error loading search index:', err);
104 this.dbInitFailed = true;
105 return;
106 }
107
108 debugLog(`📊 Loaded ${rows.length} articles for search index`);
109
110 const fuseOptions = {
111 keys: [
112 { name: 'title', weight: 0.4 },
113 { name: 'search_content', weight: 0.4 },
114 { name: 'labels', weight: 0.2 }
115 ],
116 threshold: 0.6, // 提高阈值以允许更多匹配
117 includeScore: true,
118 includeMatches: true,
119 useExtendedSearch: true, // 启用扩展搜索
120 ignoreLocation: true, // 忽略位置影响
121 findAllMatches: true, // 查找所有匹配项
122 minMatchCharLength: 1 // 最小匹配字符长度,有助于中文匹配
123 };
124
125 this.searchEngine = new Fuse(rows, fuseOptions);
126 this.isReady = true;
127 debugLog(`🎉 Search index loaded with ${rows.length} articles - Server ready!`);
128 console.error(`✅ iCSS MCP Server ready! (Debug mode: ${isDebugMode})`);
129 });
130 }
131
132 async waitForReady(timeout = 10000) {
133 debugLog(`⏳ Waiting for server to be ready (timeout: ${timeout}ms)`);

Callers 1

initializeDatabaseMethod · 0.95

Calls 1

debugLogFunction · 0.70

Tested by

no test coverage detected