| 62 | } |
| 63 | |
| 64 | async testSearchFunction(query = "透明 边框") { |
| 65 | console.log(`\n🔍 Testing search for: "${query}"`); |
| 66 | |
| 67 | if (!this.isReady) { |
| 68 | console.error('❌ Search engine not ready'); |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | const startTime = Date.now(); |
| 73 | |
| 74 | try { |
| 75 | const results = this.searchEngine.search(query).slice(0, 5); |
| 76 | const endTime = Date.now(); |
| 77 | |
| 78 | console.log(`⏱️ Search completed in ${endTime - startTime}ms`); |
| 79 | console.log(`📋 Found ${results.length} results`); |
| 80 | |
| 81 | results.forEach((result, index) => { |
| 82 | const item = result.item; |
| 83 | console.log(`\n${index + 1}. ${item.title}`); |
| 84 | console.log(` Issue #${item.number}`); |
| 85 | console.log(` Score: ${Math.round((1 - result.score) * 100)}%`); |
| 86 | console.log(` URL: ${item.html_url}`); |
| 87 | |
| 88 | if (result.matches) { |
| 89 | console.log(` Matches: ${result.matches.length}`); |
| 90 | result.matches.forEach(match => { |
| 91 | console.log(` - ${match.key}: ${match.value?.substring(0, 50)}...`); |
| 92 | }); |
| 93 | } |
| 94 | }); |
| 95 | |
| 96 | return results; |
| 97 | |
| 98 | } catch (error) { |
| 99 | console.error('❌ Search failed:', error.message); |
| 100 | console.error(error.stack); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | async testSpecificArticle(issueNumber = 1) { |
| 105 | console.log(`\n📄 Testing get article #${issueNumber}`); |