[{"data":1,"prerenderedAt":57},["Reactive",2],{"blog-post-markdown-search-indexing-optimization-complete-guide":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":31,"related":32},"markdown-search-indexing-optimization-complete-guide","Markdown Search Indexing and Optimization: Complete Guide for Full-Text Search Systems and Content Discovery","Master advanced Markdown search indexing techniques for building powerful full-text search systems, content discovery platforms, and intelligent documentation search. Learn search optimization, ranking algorithms, and indexing strategies.","Advanced Markdown search indexing and optimization systems enable sophisticated content discovery platforms that provide users with intelligent, contextual search capabilities across large…","2025-10-26","Tutorial","Matthew Rathbone","markdown search indexing, full-text search markdown, markdown search optimization, content discovery systems, documentation search, markdown search algorithms, text indexing, search ranking",22,"\u003Cp>Advanced Markdown search indexing and optimization systems enable sophisticated content discovery platforms that provide users with intelligent, contextual search capabilities across large documentation repositories and content management systems. By implementing comprehensive search indexing strategies, semantic analysis techniques, and intelligent ranking algorithms, technical teams can build powerful search experiences that help users find relevant information quickly while maintaining search performance and accuracy across complex content hierarchies.\u003C/p>\n\u003Ch2 id=\"why-master-markdown-search-indexing\">Why Master Markdown Search Indexing?\u003C/h2>\n\u003Cp>Professional search indexing provides essential benefits for content-heavy systems:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Enhanced Discoverability\u003C/strong>: Enable users to find relevant content quickly through intelligent search algorithms\u003C/li>\n\u003Cli>\u003Cstrong>Semantic Understanding\u003C/strong>: Implement context-aware search that understands content relationships and user intent\u003C/li>\n\u003Cli>\u003Cstrong>Performance Optimization\u003C/strong>: Build fast, scalable search systems that handle large content repositories efficiently\u003C/li>\n\u003Cli>\u003Cstrong>User Experience\u003C/strong>: Provide personalized, relevant search results that adapt to user behavior and preferences\u003C/li>\n\u003Cli>\u003Cstrong>Content Intelligence\u003C/strong>: Extract insights about content usage, popular topics, and knowledge gaps\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"foundation-search-architecture\">Foundation Search Architecture\u003C/h2>\n\u003Ch3 id=\"basic-full-text-search-implementation\">Basic Full-Text Search Implementation\u003C/h3>\n\u003Cp>Understanding fundamental search indexing concepts for Markdown content:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// markdown-search-engine.js - Advanced search indexing system\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> matter = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;gray-matter&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> lunr = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;lunr&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> natural = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;natural&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownSearchEngine\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span> = options.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">indexPath\u003C/span> = options.\u003Cspan class=\"hljs-property\">indexPath\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;./search-index.json&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stopWords\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(options.\u003Cspan class=\"hljs-property\">stopWords\u003C/span> || natural.\u003Cspan class=\"hljs-property\">stopwords\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stemmer\u003C/span> = options.\u003Cspan class=\"hljs-property\">stemmer\u003C/span> || natural.\u003Cspan class=\"hljs-property\">PorterStemmer\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Search configuration\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">config\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">boostTitle\u003C/span>: options.\u003Cspan class=\"hljs-property\">boostTitle\u003C/span> || \u003Cspan class=\"hljs-number\">10\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">boostHeadings\u003C/span>: options.\u003Cspan class=\"hljs-property\">boostHeadings\u003C/span> || \u003Cspan class=\"hljs-number\">5\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">boostKeywords\u003C/span>: options.\u003Cspan class=\"hljs-property\">boostKeywords\u003C/span> || \u003Cspan class=\"hljs-number\">3\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxResults\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxResults\u003C/span> || \u003Cspan class=\"hljs-number\">20\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">minScore\u003C/span>: options.\u003Cspan class=\"hljs-property\">minScore\u003C/span> || \u003Cspan class=\"hljs-number\">0.1\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableFuzzy\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableFuzzy\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">fuzzyDistance\u003C/span>: options.\u003Cspan class=\"hljs-property\">fuzzyDistance\u003C/span> || \u003Cspan class=\"hljs-number\">2\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchIndex\u003C/span> = \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">totalDocuments\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalWords\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">uniqueWords\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgDocumentLength\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">buildIndex\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Building search index...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Clear existing data\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span> = { \u003Cspan class=\"hljs-attr\">totalDocuments\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">totalWords\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">uniqueWords\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">avgDocumentLength\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> };\n        \n        \u003Cspan class=\"hljs-comment\">// Find and process all markdown files\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> markdownFiles = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> processedDocs = [];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalWordCount = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> globalWordFreq = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath \u003Cspan class=\"hljs-keyword\">of\u003C/span> markdownFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processDocument\u003C/span>(filePath);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc) {\n                    processedDocs.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(doc);\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(doc.\u003Cspan class=\"hljs-property\">id\u003C/span>, doc);\n                    totalWordCount += doc.\u003Cspan class=\"hljs-property\">wordCount\u003C/span>;\n                    \n                    \u003Cspan class=\"hljs-comment\">// Update global word frequency for IDF calculation\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [word, freq] \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>) {\n                        globalWordFreq.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(word, (globalWordFreq.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(word) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                    }\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error processing \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate content statistics\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">totalDocuments\u003C/span>: processedDocs.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalWords\u003C/span>: totalWordCount,\n            \u003Cspan class=\"hljs-attr\">uniqueWords\u003C/span>: globalWordFreq.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgDocumentLength\u003C/span>: totalWordCount / processedDocs.\u003Cspan class=\"hljs-property\">length\u003C/span> || \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Build Lunr search index\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchIndex\u003C/span> = \u003Cspan class=\"hljs-title function_\">lunr\u003C/span>(\u003Cspan class=\"hljs-keyword\">function\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">ref\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;id&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">10\u003C/span> });\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;description&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">5\u003C/span> });\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;headings&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">3\u003C/span> });\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span> });\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">8\u003C/span> });\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">field\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;category&#x27;\u003C/span>, { \u003Cspan class=\"hljs-attr\">boost\u003C/span>: \u003Cspan class=\"hljs-number\">2\u003C/span> });\n            \n            \u003Cspan class=\"hljs-comment\">// Enable stemming and stop word filtering\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">use\u003C/span>(lunr.\u003Cspan class=\"hljs-property\">stemmer\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">separator\u003C/span> = \u003Cspan class=\"hljs-regexp\">/[\\s\\-]+/\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> processedDocs) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">id\u003C/span>: doc.\u003Cspan class=\"hljs-property\">id\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">title\u003C/span>: doc.\u003Cspan class=\"hljs-property\">title\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">description\u003C/span>: doc.\u003Cspan class=\"hljs-property\">description\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">headings\u003C/span>: doc.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>),\n                    \u003Cspan class=\"hljs-attr\">content\u003C/span>: doc.\u003Cspan class=\"hljs-property\">content\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: doc.\u003Cspan class=\"hljs-property\">keywords\u003C/span>.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>),\n                    \u003Cspan class=\"hljs-attr\">category\u003C/span>: doc.\u003Cspan class=\"hljs-property\">category\u003C/span>\n                });\n            }\n        });\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Search index built: \u003Cspan class=\"hljs-subst\">${processedDocs.length}\u003C/span> documents indexed`\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchIndex\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(\u003Cspan class=\"hljs-params\">directory\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = [];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span> = \u003Cspan class=\"hljs-keyword\">async\u003C/span> (\u003Cspan class=\"hljs-params\">dir\u003C/span>) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(dir, { \u003Cspan class=\"hljs-attr\">withFileTypes\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> entry \u003Cspan class=\"hljs-keyword\">of\u003C/span> entries) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(dir, entry.\u003Cspan class=\"hljs-property\">name\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isDirectory\u003C/span>() &amp;&amp; !entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(fullPath);\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isFile\u003C/span>() &amp;&amp; entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)) {\n                    files.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(fullPath);\n                }\n            }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(directory);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> files;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processDocument\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { \u003Cspan class=\"hljs-attr\">data\u003C/span>: frontmatter, \u003Cspan class=\"hljs-attr\">content\u003C/span>: body } = \u003Cspan class=\"hljs-title function_\">matter\u003C/span>(content);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!frontmatter.\u003Cspan class=\"hljs-property\">title\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>; \u003Cspan class=\"hljs-comment\">// Skip documents without titles\u003C/span>\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Extract document structure\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headings = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractHeadings\u003C/span>(body);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> plainContent = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">stripMarkdown\u003C/span>(body);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sentences = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractSentences\u003C/span>(plainContent);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> words = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractWords\u003C/span>(plainContent);\n        \n        \u003Cspan class=\"hljs-comment\">// Calculate term frequency\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> termFrequency = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateTermFrequency\u003C/span>(words);\n        \n        \u003Cspan class=\"hljs-comment\">// Extract key phrases\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keyPhrases = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractKeyPhrases\u003C/span>(plainContent, headings);\n        \n        \u003Cspan class=\"hljs-comment\">// Generate document summary\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> summary = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateSummary\u003C/span>(sentences, \u003Cspan class=\"hljs-number\">3\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = {\n            \u003Cspan class=\"hljs-attr\">id\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateDocumentId\u003C/span>(filePath),\n            filePath,\n            \u003Cspan class=\"hljs-attr\">title\u003C/span>: frontmatter.\u003Cspan class=\"hljs-property\">title\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">description\u003C/span>: frontmatter.\u003Cspan class=\"hljs-property\">description\u003C/span> || summary,\n            \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">isArray\u003C/span>(frontmatter.\u003Cspan class=\"hljs-property\">keywords\u003C/span>) \n                ? frontmatter.\u003Cspan class=\"hljs-property\">keywords\u003C/span> \n                : (frontmatter.\u003Cspan class=\"hljs-property\">keywords\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;,&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">k\u003C/span> =&gt;\u003C/span> k.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>()).\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-title class_\">Boolean\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">category\u003C/span>: frontmatter.\u003Cspan class=\"hljs-property\">category\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;general&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">author\u003C/span>: frontmatter.\u003Cspan class=\"hljs-property\">author\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">date\u003C/span>: frontmatter.\u003Cspan class=\"hljs-property\">date\u003C/span>,\n            headings,\n            \u003Cspan class=\"hljs-attr\">content\u003C/span>: plainContent,\n            sentences,\n            \u003Cspan class=\"hljs-attr\">wordCount\u003C/span>: words.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            termFrequency,\n            keyPhrases,\n            summary,\n            \u003Cspan class=\"hljs-attr\">url\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateDocumentUrl\u003C/span>(filePath),\n            \u003Cspan class=\"hljs-attr\">lastModified\u003C/span>: (\u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(filePath)).\u003Cspan class=\"hljs-property\">mtime\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> doc;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateDocumentId\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Buffer\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(filePath).\u003Cspan class=\"hljs-title function_\">toString\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;base64&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[^a-zA-Z0-9]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateDocumentUrl\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Convert file path to URL path\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> relativePath = path.\u003Cspan class=\"hljs-title function_\">relative\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span>, filePath);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;/&#x27;\u003C/span> + relativePath.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\.md$/\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\\\/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;/&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractHeadings\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headingPattern = \u003Cspan class=\"hljs-regexp\">/^#{1,6}\\s+(.+)$/gm\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headings = [];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> match;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = headingPattern.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(markdown)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            headings.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(match[\u003Cspan class=\"hljs-number\">1\u003C/span>].\u003Cspan class=\"hljs-title function_\">trim\u003C/span>());\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> headings;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">stripMarkdown\u003C/span>(\u003Cspan class=\"hljs-params\">markdown\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> markdown\n            \u003Cspan class=\"hljs-comment\">// Remove code blocks\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/```[\\s\\S]*?```/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/`[^`]+`/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove links but keep text\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\[([^\\]]+)\\]\\([^)]+\\)/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\[([^\\]]+)\\]\\[[^\\]]*\\]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove reference definitions\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^\\[([^\\]]+)\\]:\\s*.+$/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove images\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/!\\[([^\\]]*)\\]\\([^)]+\\)/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove emphasis\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\*\\*([^*]+)\\*\\*/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\*([^*]+)\\*/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/__([^_]+)__/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/_([^_]+)_/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;$1&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove headings markers\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^#{1,6}\\s+/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove horizontal rules\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^---+$/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove blockquote markers\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^&gt;\\s+/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Remove list markers\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^[\\s]*[-*+]\\s+/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^[\\s]*\\d+\\.\\s+/gm\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \u003Cspan class=\"hljs-comment\">// Clean up whitespace\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\n{3,}/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;\\n\\n&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractSentences\u003C/span>(\u003Cspan class=\"hljs-params\">text\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Simple sentence boundary detection\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> text\n            .\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[.!?]+/\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">s\u003C/span> =&gt;\u003C/span> s.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>())\n            .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">s\u003C/span> =&gt;\u003C/span> s.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">10\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractWords\u003C/span>(\u003Cspan class=\"hljs-params\">text\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> text\n            .\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>()\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[^\\w\\s]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\s+/\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> word.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">2\u003C/span> &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stopWords\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(word))\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stemmer\u003C/span>.\u003Cspan class=\"hljs-title function_\">stem\u003C/span>(word));\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateTermFrequency\u003C/span>(\u003Cspan class=\"hljs-params\">words\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> frequency = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalWords = words.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> word \u003Cspan class=\"hljs-keyword\">of\u003C/span> words) {\n            frequency.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(word, (frequency.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(word) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Convert to relative frequency\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [word, count] \u003Cspan class=\"hljs-keyword\">of\u003C/span> frequency) {\n            frequency.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(word, count / totalWords);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> frequency;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractKeyPhrases\u003C/span>(\u003Cspan class=\"hljs-params\">text, headings\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> phrases = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Extract phrases from headings (high value)\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> words = heading.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\s+/\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (words.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt;= \u003Cspan class=\"hljs-number\">2\u003C/span> &amp;&amp; words.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt;= \u003Cspan class=\"hljs-number\">4\u003C/span>) {\n                phrases.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(heading.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>());\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Extract 2-3 word phrases from content\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> words = text.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\s+/\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; words.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> bigram = words[i] + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + words[i + \u003Cspan class=\"hljs-number\">1\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isValidPhrase\u003C/span>(bigram)) {\n                phrases.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(bigram);\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (i &lt; words.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">2\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> trigram = words[i] + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + words[i + \u003Cspan class=\"hljs-number\">1\u003C/span>] + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + words[i + \u003Cspan class=\"hljs-number\">2\u003C/span>];\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isValidPhrase\u003C/span>(trigram)) {\n                    phrases.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(trigram);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(phrases).\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">20\u003C/span>); \u003Cspan class=\"hljs-comment\">// Limit key phrases\u003C/span>\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">isValidPhrase\u003C/span>(\u003Cspan class=\"hljs-params\">phrase\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> words = phrase.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> words.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt;= \u003Cspan class=\"hljs-number\">2\u003C/span> \n            &amp;&amp; words.\u003Cspan class=\"hljs-title function_\">every\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> word.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">2\u003C/span>)\n            &amp;&amp; !words.\u003Cspan class=\"hljs-title function_\">every\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stopWords\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(word));\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateSummary\u003C/span>(\u003Cspan class=\"hljs-params\">sentences, maxSentences\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!sentences.\u003Cspan class=\"hljs-property\">length\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Simple extractive summarization - take first few sentences\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> sentences\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, maxSentences)\n            .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;. &#x27;\u003C/span>) + \u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">search\u003C/span>(\u003Cspan class=\"hljs-params\">query, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchIndex\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">throw\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Search index not built. Call buildIndex() first.&#x27;\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchOptions = {\n            \u003Cspan class=\"hljs-attr\">maxResults\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxResults\u003C/span> || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">config\u003C/span>.\u003Cspan class=\"hljs-property\">maxResults\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">enableFuzzy\u003C/span>: options.\u003Cspan class=\"hljs-property\">enableFuzzy\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">boostRecent\u003C/span>: options.\u003Cspan class=\"hljs-property\">boostRecent\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">category\u003C/span>: options.\u003Cspan class=\"hljs-property\">category\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">author\u003C/span>: options.\u003Cspan class=\"hljs-property\">author\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">minScore\u003C/span>: options.\u003Cspan class=\"hljs-property\">minScore\u003C/span> || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">config\u003C/span>.\u003Cspan class=\"hljs-property\">minScore\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Preprocess query\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> processedQuery = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">preprocessQuery\u003C/span>(query, searchOptions);\n        \n        \u003Cspan class=\"hljs-comment\">// Perform search\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> results = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchIndex\u003C/span>.\u003Cspan class=\"hljs-title function_\">search\u003C/span>(processedQuery);\n        \n        \u003Cspan class=\"hljs-comment\">// Enhanced scoring and filtering\u003C/span>\n        results = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">enhanceResults\u003C/span>(results, query, searchOptions);\n        \n        \u003Cspan class=\"hljs-comment\">// Apply filters\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (searchOptions.\u003Cspan class=\"hljs-property\">category\u003C/span> || searchOptions.\u003Cspan class=\"hljs-property\">author\u003C/span>) {\n            results = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">applyFilters\u003C/span>(results, searchOptions);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Sort and limit results\u003C/span>\n        results = results\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> b.\u003Cspan class=\"hljs-property\">enhancedScore\u003C/span> - a.\u003Cspan class=\"hljs-property\">enhancedScore\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, searchOptions.\u003Cspan class=\"hljs-property\">maxResults\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            query,\n            \u003Cspan class=\"hljs-attr\">results\u003C/span>: results.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">result\u003C/span> =&gt;\u003C/span> ({\n                ...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(result.\u003Cspan class=\"hljs-property\">ref\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">score\u003C/span>: result.\u003Cspan class=\"hljs-property\">enhancedScore\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">matchedTerms\u003C/span>: result.\u003Cspan class=\"hljs-property\">matchedTerms\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">highlights\u003C/span>: result.\u003Cspan class=\"hljs-property\">highlights\u003C/span>\n            })),\n            \u003Cspan class=\"hljs-attr\">stats\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalResults\u003C/span>: results.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">searchTime\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - searchOptions.\u003Cspan class=\"hljs-property\">startTime\u003C/span>\n            }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">preprocessQuery\u003C/span>(\u003Cspan class=\"hljs-params\">query, options\u003C/span>) {\n        options.\u003Cspan class=\"hljs-property\">startTime\u003C/span> = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Clean and tokenize query\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> processedQuery = query\n            .\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>()\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[^\\w\\s]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Handle phrase queries\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (query.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&quot;&#x27;\u003C/span>)) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> phraseMatches = query.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/&quot;([^&quot;]+)&quot;/g\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (phraseMatches) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> phraseMatches.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">phrase\u003C/span> =&gt;\u003C/span> \n                    phrase.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/&quot;/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n                ).\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Add fuzzy search if enabled\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">enableFuzzy\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> terms = processedQuery.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> fuzzyTerms = terms.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (term.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">3\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${term}\u003C/span>~\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.config.fuzzyDistance}\u003C/span> \u003Cspan class=\"hljs-subst\">${term}\u003C/span>^2`\u003C/span>;\n                }\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> term;\n            });\n            processedQuery = fuzzyTerms.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> processedQuery;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">enhanceResults\u003C/span>(\u003Cspan class=\"hljs-params\">results, originalQuery, options\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> queryTerms = originalQuery.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\s+/\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">result\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(result.\u003Cspan class=\"hljs-property\">ref\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!doc) \u003Cspan class=\"hljs-keyword\">return\u003C/span> result;\n            \n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> enhancedScore = result.\u003Cspan class=\"hljs-property\">score\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> matchedTerms = [];\n            \n            \u003Cspan class=\"hljs-comment\">// Title match boost\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(originalQuery.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())) {\n                enhancedScore *= \u003Cspan class=\"hljs-number\">2.0\u003C/span>;\n                matchedTerms.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Exact phrase match boost\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">content\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(originalQuery.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())) {\n                enhancedScore *= \u003Cspan class=\"hljs-number\">1.5\u003C/span>;\n                matchedTerms.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;exact_phrase&#x27;\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Keyword match boost\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> keyword \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">keywords\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (queryTerms.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> keyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(term))) {\n                    enhancedScore *= \u003Cspan class=\"hljs-number\">1.3\u003C/span>;\n                    matchedTerms.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;keyword&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Heading match boost\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (queryTerms.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> heading.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(term))) {\n                    enhancedScore *= \u003Cspan class=\"hljs-number\">1.2\u003C/span>;\n                    matchedTerms.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;heading&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Recency boost if enabled\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">boostRecent\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">date\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> daysSincePublished = (\u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>(doc.\u003Cspan class=\"hljs-property\">date\u003C/span>).\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>()) / (\u003Cspan class=\"hljs-number\">1000\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">24\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (daysSincePublished &lt; \u003Cspan class=\"hljs-number\">30\u003C/span>) {\n                    enhancedScore *= \u003Cspan class=\"hljs-number\">1.1\u003C/span>;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Generate highlights\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> highlights = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateHighlights\u003C/span>(doc, queryTerms);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                ...result,\n                enhancedScore,\n                \u003Cspan class=\"hljs-attr\">matchedTerms\u003C/span>: [...\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(matchedTerms)],\n                highlights\n            };\n        }).\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">result\u003C/span> =&gt;\u003C/span> result.\u003Cspan class=\"hljs-property\">enhancedScore\u003C/span> &gt;= options.\u003Cspan class=\"hljs-property\">minScore\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateHighlights\u003C/span>(\u003Cspan class=\"hljs-params\">doc, queryTerms\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> highlights = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Find relevant sentences with query terms\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> sentence \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">sentences\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> lowerSentence = sentence.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> matchingTerms = queryTerms.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> \n                lowerSentence.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(term.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())\n            );\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (matchingTerms.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">let\u003C/span> highlighted = sentence;\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> term \u003Cspan class=\"hljs-keyword\">of\u003C/span> matchingTerms) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> regex = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">RegExp\u003C/span>(\u003Cspan class=\"hljs-string\">`(\u003Cspan class=\"hljs-subst\">${term}\u003C/span>)`\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;gi&#x27;\u003C/span>);\n                    highlighted = highlighted.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(regex, \u003Cspan class=\"hljs-string\">&#x27;&lt;mark&gt;$1&lt;/mark&gt;&#x27;\u003C/span>);\n                }\n                \n                highlights.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">text\u003C/span>: highlighted,\n                    \u003Cspan class=\"hljs-attr\">matchCount\u003C/span>: matchingTerms.\u003Cspan class=\"hljs-property\">length\u003C/span>\n                });\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (highlights.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt;= \u003Cspan class=\"hljs-number\">3\u003C/span>) \u003Cspan class=\"hljs-keyword\">break\u003C/span>; \u003Cspan class=\"hljs-comment\">// Limit highlights\u003C/span>\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> highlights;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">applyFilters\u003C/span>(\u003Cspan class=\"hljs-params\">results, options\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">result\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(result.\u003Cspan class=\"hljs-property\">ref\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">category\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">category\u003C/span> !== options.\u003Cspan class=\"hljs-property\">category\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">author\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">author\u003C/span> !== options.\u003Cspan class=\"hljs-property\">author\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">saveIndex\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> indexData = {\n            \u003Cspan class=\"hljs-attr\">documents\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()),\n            \u003Cspan class=\"hljs-attr\">stats\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">buildTime\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">version\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;1.0&#x27;\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">indexPath\u003C/span>, \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(indexData, \u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-number\">2\u003C/span>));\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Search index saved to \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.indexPath}\u003C/span>`\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">loadIndex\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> indexData = \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(\u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">indexPath\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>));\n            \n            \u003Cspan class=\"hljs-comment\">// Rebuild document map\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> indexData.\u003Cspan class=\"hljs-property\">documents\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(doc.\u003Cspan class=\"hljs-property\">id\u003C/span>, doc);\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span> = indexData.\u003Cspan class=\"hljs-property\">stats\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Rebuild search index\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildIndex\u003C/span>();\n            \n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Search index loaded: \u003Cspan class=\"hljs-subst\">${indexData.documents.length}\u003C/span> documents`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Failed to load search index:&#x27;\u003C/span>, error.\u003Cspan class=\"hljs-property\">message\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getSearchSuggestions\u003C/span>(\u003Cspan class=\"hljs-params\">query, limit = \u003Cspan class=\"hljs-number\">10\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!query || query.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt; \u003Cspan class=\"hljs-number\">2\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> [];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> suggestions = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lowerQuery = query.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Collect suggestions from titles, headings, and key phrases\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n            \u003Cspan class=\"hljs-comment\">// From titles\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(lowerQuery)) {\n                suggestions.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(doc.\u003Cspan class=\"hljs-property\">title\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// From headings\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(lowerQuery)) {\n                    suggestions.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(heading);\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// From key phrases\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> phrase \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">keyPhrases\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (phrase.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(lowerQuery)) {\n                    suggestions.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(phrase);\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// From keywords\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> keyword \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">keywords\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (keyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(lowerQuery)) {\n                    suggestions.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(keyword);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(suggestions)\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-comment\">// Prefer suggestions that start with query\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> aStarts = a.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(lowerQuery);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> bStarts = b.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(lowerQuery);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (aStarts &amp;&amp; !bStarts) \u003Cspan class=\"hljs-keyword\">return\u003C/span> -\u003Cspan class=\"hljs-number\">1\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!aStarts &amp;&amp; bStarts) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">1\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> a.\u003Cspan class=\"hljs-property\">length\u003C/span> - b.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            })\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, limit);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getPopularSearches\u003C/span>(\u003Cspan class=\"hljs-params\">limit = \u003Cspan class=\"hljs-number\">10\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// This would typically be implemented with search analytics\u003C/span>\n        \u003Cspan class=\"hljs-comment\">// For now, return most common key phrases\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> phraseFreq = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> phrase \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">keyPhrases\u003C/span>) {\n                phraseFreq.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(phrase, (phraseFreq.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(phrase) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(phraseFreq.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>())\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[, a], [, b]\u003C/span>) =&gt;\u003C/span> b - a)\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, limit)\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[phrase, count]\u003C/span>) =&gt;\u003C/span> ({ phrase, count }));\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateSearchAnalytics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> analytics = {\n            \u003Cspan class=\"hljs-attr\">indexStats\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentStats\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">contentBreakdown\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeContentBreakdown\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">topKeywords\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getTopKeywords\u003C/span>(\u003Cspan class=\"hljs-number\">20\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">contentGaps\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">identifyContentGaps\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateContentRecommendations\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> analytics;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">analyzeContentBreakdown\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> breakdown = {\n            \u003Cspan class=\"hljs-attr\">byCategory\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">byAuthor\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">byMonth\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">wordCountDistribution\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n            \u003Cspan class=\"hljs-comment\">// By category\u003C/span>\n            breakdown.\u003Cspan class=\"hljs-property\">byCategory\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(\n                doc.\u003Cspan class=\"hljs-property\">category\u003C/span>, \n                (breakdown.\u003Cspan class=\"hljs-property\">byCategory\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(doc.\u003Cspan class=\"hljs-property\">category\u003C/span>) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n            );\n            \n            \u003Cspan class=\"hljs-comment\">// By author\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">author\u003C/span>) {\n                breakdown.\u003Cspan class=\"hljs-property\">byAuthor\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(\n                    doc.\u003Cspan class=\"hljs-property\">author\u003C/span>,\n                    (breakdown.\u003Cspan class=\"hljs-property\">byAuthor\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(doc.\u003Cspan class=\"hljs-property\">author\u003C/span>) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n                );\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// By month\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">date\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> month = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>(doc.\u003Cspan class=\"hljs-property\">date\u003C/span>).\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>().\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">7\u003C/span>);\n                breakdown.\u003Cspan class=\"hljs-property\">byMonth\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(\n                    month,\n                    (breakdown.\u003Cspan class=\"hljs-property\">byMonth\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(month) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n                );\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Word count distribution\u003C/span>\n            breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(doc.\u003Cspan class=\"hljs-property\">wordCount\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">byCategory\u003C/span>: \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">fromEntries\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byCategory\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">byAuthor\u003C/span>: \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">fromEntries\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byAuthor\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">byMonth\u003C/span>: \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">fromEntries\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byMonth\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">avgWordCount\u003C/span>: breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a + b, \u003Cspan class=\"hljs-number\">0\u003C/span>) / breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">wordCountRanges\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">short\u003C/span>: breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">wc\u003C/span> =&gt;\u003C/span> wc &lt; \u003Cspan class=\"hljs-number\">500\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">medium\u003C/span>: breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">wc\u003C/span> =&gt;\u003C/span> wc &gt;= \u003Cspan class=\"hljs-number\">500\u003C/span> &amp;&amp; wc &lt; \u003Cspan class=\"hljs-number\">2000\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">long\u003C/span>: breakdown.\u003Cspan class=\"hljs-property\">wordCountDistribution\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">wc\u003C/span> =&gt;\u003C/span> wc &gt;= \u003Cspan class=\"hljs-number\">2000\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>\n            }\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getTopKeywords\u003C/span>(\u003Cspan class=\"hljs-params\">limit\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordFreq = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> keyword \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">keywords\u003C/span>) {\n                keywordFreq.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(keyword, (keywordFreq.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(keyword) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(keywordFreq.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>())\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[, a], [, b]\u003C/span>) =&gt;\u003C/span> b - a)\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, limit)\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[keyword, count]\u003C/span>) =&gt;\u003C/span> ({ keyword, count }));\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">identifyContentGaps\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Analyze search patterns vs available content\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> gaps = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Find topics mentioned but not covered in depth\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> allWords = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> titleWords = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n            \u003Cspan class=\"hljs-comment\">// Count all words\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [word, freq] \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>) {\n                allWords.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(word, (allWords.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(word) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + freq);\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Track title words (topics covered)\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> titleWordsList = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractWords\u003C/span>(doc.\u003Cspan class=\"hljs-property\">title\u003C/span>);\n            titleWordsList.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> titleWords.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(word));\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Find frequently mentioned words that aren&#x27;t main topics\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedWords = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(allWords.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>())\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[, a], [, b]\u003C/span>) =&gt;\u003C/span> b - a)\n            .\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">100\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [word, frequency] \u003Cspan class=\"hljs-keyword\">of\u003C/span> sortedWords) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!titleWords.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(word) &amp;&amp; frequency &gt; \u003Cspan class=\"hljs-number\">0.001\u003C/span>) {\n                gaps.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">topic\u003C/span>: word,\n                    \u003Cspan class=\"hljs-attr\">mentions\u003C/span>: frequency,\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;underrepresented&#x27;\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> gaps.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">20\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateContentRecommendations\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recommendations = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> breakdown = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeContentBreakdown\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Recommend based on content distribution\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedCategories = \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byCategory\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[, a], [, b]\u003C/span>) =&gt;\u003C/span> b - a);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (sortedCategories.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> [topCategory, topCount] = sortedCategories[\u003Cspan class=\"hljs-number\">0\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> [, secondCount] = sortedCategories[\u003Cspan class=\"hljs-number\">1\u003C/span>] || [\u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>];\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (topCount &gt; secondCount * \u003Cspan class=\"hljs-number\">3\u003C/span>) {\n                recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;diversification&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">suggestion\u003C/span>: \u003Cspan class=\"hljs-string\">`Consider creating more content for underrepresented categories. &quot;\u003Cspan class=\"hljs-subst\">${topCategory}\u003C/span>&quot; has \u003Cspan class=\"hljs-subst\">${topCount}\u003C/span> documents while others have fewer.`\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Recommend based on word count\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (breakdown.\u003Cspan class=\"hljs-property\">avgWordCount\u003C/span> &lt; \u003Cspan class=\"hljs-number\">800\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;depth&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;low&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">suggestion\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider adding more detailed content. Average word count is below recommended 800+ words.&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Recommend based on recency\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recentContent = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>())\n            .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!doc.\u003Cspan class=\"hljs-property\">date\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> daysSince = (\u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>(doc.\u003Cspan class=\"hljs-property\">date\u003C/span>).\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>()) / (\u003Cspan class=\"hljs-number\">1000\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">24\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> daysSince &lt; \u003Cspan class=\"hljs-number\">30\u003C/span>;\n            }).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (recentContent === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;freshness&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">suggestion\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;No content published in the last 30 days. Consider adding fresh content to maintain relevance.&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recommendations;\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownSearchEngine\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch3 id=\"advanced-search-ui-components\">Advanced Search UI Components\u003C/h3>\n\u003Cp>Creating user-friendly search interfaces with intelligent features:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// search-ui-components.js - Advanced search interface components\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">AdvancedSearchUI\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">searchEngine, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span> = searchEngine;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">container\u003C/span> = options.\u003Cspan class=\"hljs-property\">container\u003C/span> || \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-property\">body\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">debounceDelay\u003C/span> = options.\u003Cspan class=\"hljs-property\">debounceDelay\u003C/span> || \u003Cspan class=\"hljs-number\">300\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">minQueryLength\u003C/span> = options.\u003Cspan class=\"hljs-property\">minQueryLength\u003C/span> || \u003Cspan class=\"hljs-number\">2\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">loadSearchHistory\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">isSearching\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">initializeUI\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">bindEvents\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">initializeUI\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">container\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = \u003Cspan class=\"hljs-string\">`\n            &lt;div class=&quot;advanced-search-container&quot;&gt;\n                &lt;div class=&quot;search-header&quot;&gt;\n                    &lt;div class=&quot;search-input-wrapper&quot;&gt;\n                        &lt;input type=&quot;text&quot; \n                               id=&quot;search-input&quot; \n                               placeholder=&quot;Search documentation...&quot; \n                               autocomplete=&quot;off&quot;&gt;\n                        &lt;button id=&quot;search-button&quot; type=&quot;button&quot;&gt;\n                            &lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot;&gt;\n                                &lt;path d=&quot;M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z&quot;/&gt;\n                            &lt;/svg&gt;\n                        &lt;/button&gt;\n                    &lt;/div&gt;\n                    \n                    &lt;div class=&quot;search-filters&quot; style=&quot;display: none;&quot;&gt;\n                        &lt;select id=&quot;category-filter&quot;&gt;\n                            &lt;option value=&quot;&quot;&gt;All Categories&lt;/option&gt;\n                        &lt;/select&gt;\n                        &lt;select id=&quot;author-filter&quot;&gt;\n                            &lt;option value=&quot;&quot;&gt;All Authors&lt;/option&gt;\n                        &lt;/select&gt;\n                        &lt;label&gt;\n                            &lt;input type=&quot;checkbox&quot; id=&quot;recent-boost&quot;&gt; Recent content first\n                        &lt;/label&gt;\n                    &lt;/div&gt;\n                    \n                    &lt;button id=&quot;toggle-filters&quot; type=&quot;button&quot;&gt;Filters&lt;/button&gt;\n                &lt;/div&gt;\n                \n                &lt;div class=&quot;search-suggestions&quot; id=&quot;search-suggestions&quot; style=&quot;display: none;&quot;&gt;\n                    &lt;div class=&quot;suggestions-header&quot;&gt;Suggestions&lt;/div&gt;\n                    &lt;div class=&quot;suggestions-list&quot;&gt;&lt;/div&gt;\n                &lt;/div&gt;\n                \n                &lt;div class=&quot;search-results&quot; id=&quot;search-results&quot; style=&quot;display: none;&quot;&gt;\n                    &lt;div class=&quot;results-header&quot;&gt;\n                        &lt;div class=&quot;results-count&quot;&gt;&lt;/div&gt;\n                        &lt;div class=&quot;results-time&quot;&gt;&lt;/div&gt;\n                    &lt;/div&gt;\n                    &lt;div class=&quot;results-list&quot;&gt;&lt;/div&gt;\n                    &lt;div class=&quot;results-pagination&quot; style=&quot;display: none;&quot;&gt;&lt;/div&gt;\n                &lt;/div&gt;\n                \n                &lt;div class=&quot;search-history&quot; id=&quot;search-history&quot; style=&quot;display: none;&quot;&gt;\n                    &lt;div class=&quot;history-header&quot;&gt;Recent Searches&lt;/div&gt;\n                    &lt;div class=&quot;history-list&quot;&gt;&lt;/div&gt;\n                &lt;/div&gt;\n                \n                &lt;div class=&quot;popular-searches&quot; id=&quot;popular-searches&quot;&gt;\n                    &lt;div class=&quot;popular-header&quot;&gt;Popular Searches&lt;/div&gt;\n                    &lt;div class=&quot;popular-list&quot;&gt;&lt;/div&gt;\n                &lt;/div&gt;\n            &lt;/div&gt;\n        `\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">input\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;search-input&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">button\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;search-button&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">filters\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.search-filters&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">toggleFilters\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;toggle-filters&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">categoryFilter\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;category-filter&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">authorFilter\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;author-filter&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">recentBoost\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;recent-boost&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">suggestions\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;search-suggestions&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">suggestionsList\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.suggestions-list&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">results\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;search-results&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">resultsCount\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.results-count&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">resultsTime\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.results-time&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">resultsList\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.results-list&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">history\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;search-history&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">historyList\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.history-list&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">popular\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">getElementById\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;popular-searches&#x27;\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">popularList\u003C/span>: \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.popular-list&#x27;\u003C/span>)\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">populateFilters\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">displayPopularSearches\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">bindEvents\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Search input with debounce\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> searchTimeout;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;input&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">e\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-built_in\">clearTimeout\u003C/span>(searchTimeout);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> query = e.\u003Cspan class=\"hljs-property\">target\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span>.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (query.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt;= \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">minQueryLength\u003C/span>) {\n                searchTimeout = \u003Cspan class=\"hljs-built_in\">setTimeout\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(query);\n                }, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">debounceDelay\u003C/span>);\n                \n                \u003Cspan class=\"hljs-comment\">// Show suggestions immediately\u003C/span>\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">showSuggestions\u003C/span>(query);\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">clearResults\u003C/span>();\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">hideSuggestions\u003C/span>();\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">showPopular\u003C/span>();\n            }\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Search button\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">button\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;click&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span>.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>());\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Enter key\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;keydown&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">e\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (e.\u003Cspan class=\"hljs-property\">key\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;Enter&#x27;\u003C/span>) {\n                e.\u003Cspan class=\"hljs-title function_\">preventDefault\u003C/span>();\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span>.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>());\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (e.\u003Cspan class=\"hljs-property\">key\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;ArrowDown&#x27;\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">navigateSuggestions\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;down&#x27;\u003C/span>);\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (e.\u003Cspan class=\"hljs-property\">key\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;ArrowUp&#x27;\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">navigateSuggestions\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;up&#x27;\u003C/span>);\n            }\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Filter toggles\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">toggleFilters\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;click&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> isVisible = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">filters\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> !== \u003Cspan class=\"hljs-string\">&#x27;none&#x27;\u003C/span>;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">filters\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = isVisible ? \u003Cspan class=\"hljs-string\">&#x27;none&#x27;\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Filter changes\u003C/span>\n        [\u003Cspan class=\"hljs-string\">&#x27;categoryFilter&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;authorFilter&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;recentBoost&#x27;\u003C/span>].\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">filterName\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>[filterName].\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;change&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span>) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span>);\n                }\n            });\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Click outside to hide suggestions\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;click&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">e\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">container\u003C/span>.\u003Cspan class=\"hljs-title function_\">contains\u003C/span>(e.\u003Cspan class=\"hljs-property\">target\u003C/span>)) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">hideSuggestions\u003C/span>();\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">populateFilters\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> analytics = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateSearchAnalytics\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> breakdown = analytics.\u003Cspan class=\"hljs-property\">contentBreakdown\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Populate category filter\u003C/span>\n        \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">keys\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byCategory\u003C/span>).\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">category\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> option = \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">createElement\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;option&#x27;\u003C/span>);\n            option.\u003Cspan class=\"hljs-property\">value\u003C/span> = category;\n            option.\u003Cspan class=\"hljs-property\">textContent\u003C/span> = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${category}\u003C/span> (\u003Cspan class=\"hljs-subst\">${breakdown.byCategory[category]}\u003C/span>)`\u003C/span>;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">categoryFilter\u003C/span>.\u003Cspan class=\"hljs-title function_\">appendChild\u003C/span>(option);\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Populate author filter\u003C/span>\n        \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">keys\u003C/span>(breakdown.\u003Cspan class=\"hljs-property\">byAuthor\u003C/span>).\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">author\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> option = \u003Cspan class=\"hljs-variable language_\">document\u003C/span>.\u003Cspan class=\"hljs-title function_\">createElement\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;option&#x27;\u003C/span>);\n            option.\u003Cspan class=\"hljs-property\">value\u003C/span> = author;\n            option.\u003Cspan class=\"hljs-property\">textContent\u003C/span> = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${author}\u003C/span> (\u003Cspan class=\"hljs-subst\">${breakdown.byAuthor[author]}\u003C/span>)`\u003C/span>;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">authorFilter\u003C/span>.\u003Cspan class=\"hljs-title function_\">appendChild\u003C/span>(option);\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(\u003Cspan class=\"hljs-params\">query\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!query || query.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">minQueryLength\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">clearResults\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span> = query;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">isSearching\u003C/span> = \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">showLoadingState\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">hideSuggestions\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">hidePopular\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Get search options from filters\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> options = {\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">categoryFilter\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span> || \u003Cspan class=\"hljs-literal\">undefined\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">author\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">authorFilter\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span> || \u003Cspan class=\"hljs-literal\">undefined\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">boostRecent\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">recentBoost\u003C/span>.\u003Cspan class=\"hljs-property\">checked\u003C/span>\n            };\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchResults = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">search\u003C/span>(query, options);\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">displayResults\u003C/span>(searchResults);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">addToSearchHistory\u003C/span>(query);\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">displayError\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Search failed: &#x27;\u003C/span> + error.\u003Cspan class=\"hljs-property\">message\u003C/span>);\n        } \u003Cspan class=\"hljs-keyword\">finally\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">isSearching\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">showSuggestions\u003C/span>(\u003Cspan class=\"hljs-params\">query\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> suggestions = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">getSearchSuggestions\u003C/span>(query, \u003Cspan class=\"hljs-number\">8\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (suggestions.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">hideSuggestions\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestionsList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = suggestions\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">suggestion\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\n                &lt;div class=&quot;suggestion-item&quot; data-suggestion=&quot;\u003Cspan class=\"hljs-subst\">${suggestion}\u003C/span>&quot;&gt;\n                    &lt;svg width=&quot;14&quot; height=&quot;14&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot;&gt;\n                        &lt;path d=&quot;M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z&quot;/&gt;\n                    &lt;/svg&gt;\n                    \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.highlightQuery(suggestion, query)}\u003C/span>\n                &lt;/div&gt;\n            `\u003C/span>).\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Add click handlers\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestionsList\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelectorAll\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.suggestion-item&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">item\u003C/span> =&gt;\u003C/span> {\n            item.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;click&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> suggestion = item.\u003Cspan class=\"hljs-property\">dataset\u003C/span>.\u003Cspan class=\"hljs-property\">suggestion\u003C/span>;\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span> = suggestion;\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(suggestion);\n            });\n        });\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestions\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">hideSuggestions\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestions\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;none&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">displayResults\u003C/span>(\u003Cspan class=\"hljs-params\">searchResults\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { query, results, stats } = searchResults;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsCount\u003C/span>.\u003Cspan class=\"hljs-property\">textContent\u003C/span> = \n            \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${results.length}\u003C/span> result\u003Cspan class=\"hljs-subst\">${results.length !== \u003Cspan class=\"hljs-number\">1\u003C/span> ? \u003Cspan class=\"hljs-string\">&#x27;s&#x27;\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>}\u003C/span> for &quot;\u003Cspan class=\"hljs-subst\">${query}\u003C/span>&quot;`\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsTime\u003C/span>.\u003Cspan class=\"hljs-property\">textContent\u003C/span> = \n            \u003Cspan class=\"hljs-string\">`Search completed in \u003Cspan class=\"hljs-subst\">${stats.searchTime}\u003C/span>ms`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (results.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = \u003Cspan class=\"hljs-string\">`\n                &lt;div class=&quot;no-results&quot;&gt;\n                    &lt;div class=&quot;no-results-icon&quot;&gt;🔍&lt;/div&gt;\n                    &lt;h3&gt;No results found&lt;/h3&gt;\n                    &lt;p&gt;Try different keywords or check your spelling&lt;/p&gt;\n                    &lt;div class=&quot;search-suggestions-help&quot;&gt;\n                        &lt;strong&gt;Search tips:&lt;/strong&gt;\n                        &lt;ul&gt;\n                            &lt;li&gt;Use specific keywords related to your topic&lt;/li&gt;\n                            &lt;li&gt;Try synonyms or alternative terms&lt;/li&gt;\n                            &lt;li&gt;Use quotes for exact phrases: &quot;markdown table&quot;&lt;/li&gt;\n                            &lt;li&gt;Check the filters - you might have them too restrictive&lt;/li&gt;\n                        &lt;/ul&gt;\n                    &lt;/div&gt;\n                &lt;/div&gt;\n            `\u003C/span>;\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = results\n                .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">result\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">renderSearchResult\u003C/span>(result))\n                .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">results\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">renderSearchResult\u003C/span>(\u003Cspan class=\"hljs-params\">result\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> highlights = result.\u003Cspan class=\"hljs-property\">highlights\u003C/span>\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">text\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; ... &#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> matchedTermsText = result.\u003Cspan class=\"hljs-property\">matchedTerms\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> \n            ? \u003Cspan class=\"hljs-string\">`&lt;div class=&quot;matched-terms&quot;&gt;Matched: \u003Cspan class=\"hljs-subst\">${result.matchedTerms.join(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C/span>)}\u003C/span>&lt;/div&gt;`\u003C/span>\n            : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">`\n            &lt;article class=&quot;search-result&quot; data-score=&quot;\u003Cspan class=\"hljs-subst\">${result.score}\u003C/span>&quot;&gt;\n                &lt;header class=&quot;result-header&quot;&gt;\n                    &lt;h3 class=&quot;result-title&quot;&gt;\n                        &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${result.url}\u003C/span>&quot;&gt;\u003Cspan class=\"hljs-subst\">${result.title}\u003C/span>&lt;/a&gt;\n                    &lt;/h3&gt;\n                    &lt;div class=&quot;result-meta&quot;&gt;\n                        &lt;span class=&quot;result-category&quot;&gt;\u003Cspan class=\"hljs-subst\">${result.category}\u003C/span>&lt;/span&gt;\n                        \u003Cspan class=\"hljs-subst\">${result.author ? \u003Cspan class=\"hljs-string\">`&lt;span class=&quot;result-author&quot;&gt;by \u003Cspan class=\"hljs-subst\">${result.author}\u003C/span>&lt;/span&gt;`\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>}\u003C/span>\n                        \u003Cspan class=\"hljs-subst\">${result.date ? \u003Cspan class=\"hljs-string\">`&lt;span class=&quot;result-date&quot;&gt;\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-built_in\">Date\u003C/span>(result.date).toLocaleDateString()}\u003C/span>&lt;/span&gt;`\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>}\u003C/span>\n                        &lt;span class=&quot;result-score&quot;&gt;Score: \u003Cspan class=\"hljs-subst\">${result.score.toFixed(\u003Cspan class=\"hljs-number\">2\u003C/span>)}\u003C/span>&lt;/span&gt;\n                    &lt;/div&gt;\n                &lt;/header&gt;\n                \n                &lt;div class=&quot;result-description&quot;&gt;\n                    \u003Cspan class=\"hljs-subst\">${result.description}\u003C/span>\n                &lt;/div&gt;\n                \n                \u003Cspan class=\"hljs-subst\">${highlights ? \u003Cspan class=\"hljs-string\">`\n                    &lt;div class=&quot;result-highlights&quot;&gt;\n                        \u003Cspan class=\"hljs-subst\">${highlights}\u003C/span>\n                    &lt;/div&gt;\n                `\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>}\u003C/span>\n                \n                \u003Cspan class=\"hljs-subst\">${matchedTermsText}\u003C/span>\n                \n                &lt;div class=&quot;result-keywords&quot;&gt;\n                    \u003Cspan class=\"hljs-subst\">${result.keywords.slice(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">5\u003C/span>).map(keyword =&gt; \n                        \u003Cspan class=\"hljs-string\">`&lt;span class=&quot;keyword-tag&quot;&gt;\u003Cspan class=\"hljs-subst\">${keyword}\u003C/span>&lt;/span&gt;`\u003C/span>\n                    ).join(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)}\u003C/span>\n                &lt;/div&gt;\n            &lt;/article&gt;\n        `\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">displayPopularSearches\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> popularSearches = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">getPopularSearches\u003C/span>(\u003Cspan class=\"hljs-number\">10\u003C/span>);\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">popularList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = popularSearches\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">{ phrase, count }\u003C/span>) =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\n                &lt;div class=&quot;popular-item&quot; data-query=&quot;\u003Cspan class=\"hljs-subst\">${phrase}\u003C/span>&quot;&gt;\n                    &lt;span class=&quot;popular-phrase&quot;&gt;\u003Cspan class=\"hljs-subst\">${phrase}\u003C/span>&lt;/span&gt;\n                    &lt;span class=&quot;popular-count&quot;&gt;\u003Cspan class=\"hljs-subst\">${count}\u003C/span>&lt;/span&gt;\n                &lt;/div&gt;\n            `\u003C/span>).\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Add click handlers\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">popularList\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelectorAll\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.popular-item&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">item\u003C/span> =&gt;\u003C/span> {\n            item.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;click&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> query = item.\u003Cspan class=\"hljs-property\">dataset\u003C/span>.\u003Cspan class=\"hljs-property\">query\u003C/span>;\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span> = query;\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleSearch\u003C/span>(query);\n            });\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">showPopular\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">popular\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">hidePopular\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">popular\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;none&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">showLoadingState\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = \u003Cspan class=\"hljs-string\">`\n            &lt;div class=&quot;loading-state&quot;&gt;\n                &lt;div class=&quot;loading-spinner&quot;&gt;&lt;/div&gt;\n                &lt;p&gt;Searching...&lt;/p&gt;\n            &lt;/div&gt;\n        `\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">results\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">clearResults\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">results\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;none&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">displayError\u003C/span>(\u003Cspan class=\"hljs-params\">message\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">resultsList\u003C/span>.\u003Cspan class=\"hljs-property\">innerHTML\u003C/span> = \u003Cspan class=\"hljs-string\">`\n            &lt;div class=&quot;error-state&quot;&gt;\n                &lt;div class=&quot;error-icon&quot;&gt;⚠️&lt;/div&gt;\n                &lt;h3&gt;Search Error&lt;/h3&gt;\n                &lt;p&gt;\u003Cspan class=\"hljs-subst\">${message}\u003C/span>&lt;/p&gt;\n            &lt;/div&gt;\n        `\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">results\u003C/span>.\u003Cspan class=\"hljs-property\">style\u003C/span>.\u003Cspan class=\"hljs-property\">display\u003C/span> = \u003Cspan class=\"hljs-string\">&#x27;block&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">highlightQuery\u003C/span>(\u003Cspan class=\"hljs-params\">text, query\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> regex = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">RegExp\u003C/span>(\u003Cspan class=\"hljs-string\">`(\u003Cspan class=\"hljs-subst\">${query.replace(/[.*+?^${}()|[\\]\\\\]/g, \u003Cspan class=\"hljs-string\">&#x27;\\\\$&amp;&#x27;\u003C/span>)}\u003C/span>)`\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;gi&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> text.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(regex, \u003Cspan class=\"hljs-string\">&#x27;&lt;mark&gt;$1&lt;/mark&gt;&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">addToSearchHistory\u003C/span>(\u003Cspan class=\"hljs-params\">query\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Remove duplicates and add to front\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">item\u003C/span> =&gt;\u003C/span> item.\u003Cspan class=\"hljs-property\">query\u003C/span> !== query);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span>.\u003Cspan class=\"hljs-title function_\">unshift\u003C/span>({\n            query,\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">resultsCount\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">currentQuery\u003C/span> ? \u003Cspan class=\"hljs-number\">1\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span> \u003Cspan class=\"hljs-comment\">// Simplified\u003C/span>\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Limit history size\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">20\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Save to localStorage\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">localStorage\u003C/span>.\u003Cspan class=\"hljs-title function_\">setItem\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;searchHistory&#x27;\u003C/span>, \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchHistory\u003C/span>));\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">loadSearchHistory\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stored = \u003Cspan class=\"hljs-variable language_\">localStorage\u003C/span>.\u003Cspan class=\"hljs-title function_\">getItem\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;searchHistory&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> stored ? \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(stored) : [];\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> [];\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">navigateSuggestions\u003C/span>(\u003Cspan class=\"hljs-params\">direction\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> suggestions = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestionsList\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelectorAll\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.suggestion-item&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (suggestions.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentActive = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">suggestionsList\u003C/span>.\u003Cspan class=\"hljs-title function_\">querySelector\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.suggestion-active&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> newIndex = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (currentActive) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentIndex = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(suggestions).\u003Cspan class=\"hljs-title function_\">indexOf\u003C/span>(currentActive);\n            newIndex = direction === \u003Cspan class=\"hljs-string\">&#x27;down&#x27;\u003C/span> \n                ? (currentIndex + \u003Cspan class=\"hljs-number\">1\u003C/span>) % suggestions.\u003Cspan class=\"hljs-property\">length\u003C/span>\n                : (currentIndex - \u003Cspan class=\"hljs-number\">1\u003C/span> + suggestions.\u003Cspan class=\"hljs-property\">length\u003C/span>) % suggestions.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            currentActive.\u003Cspan class=\"hljs-property\">classList\u003C/span>.\u003Cspan class=\"hljs-title function_\">remove\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;suggestion-active&#x27;\u003C/span>);\n        }\n        \n        suggestions[newIndex].\u003Cspan class=\"hljs-property\">classList\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;suggestion-active&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">elements\u003C/span>.\u003Cspan class=\"hljs-property\">input\u003C/span>.\u003Cspan class=\"hljs-property\">value\u003C/span> = suggestions[newIndex].\u003Cspan class=\"hljs-property\">dataset\u003C/span>.\u003Cspan class=\"hljs-property\">suggestion\u003C/span>;\n    }\n}\n\n\u003Cspan class=\"hljs-comment\">// CSS styles for the search UI\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> searchUIStyles = \u003Cspan class=\"hljs-string\">`\n    .advanced-search-container {\n        max-width: 800px;\n        margin: 0 auto;\n        font-family: -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, sans-serif;\n    }\n    \n    .search-header {\n        display: flex;\n        gap: 1rem;\n        margin-bottom: 1rem;\n        align-items: center;\n    }\n    \n    .search-input-wrapper {\n        flex: 1;\n        position: relative;\n    }\n    \n    #search-input {\n        width: 100%;\n        padding: 12px 50px 12px 16px;\n        border: 2px solid #e2e8f0;\n        border-radius: 8px;\n        font-size: 16px;\n        outline: none;\n        transition: border-color 0.2s;\n    }\n    \n    #search-input:focus {\n        border-color: #4299e1;\n    }\n    \n    #search-button {\n        position: absolute;\n        right: 8px;\n        top: 50%;\n        transform: translateY(-50%);\n        background: none;\n        border: none;\n        color: #718096;\n        cursor: pointer;\n        padding: 8px;\n    }\n    \n    .search-filters {\n        display: flex;\n        gap: 1rem;\n        padding: 1rem;\n        background: #f7fafc;\n        border-radius: 8px;\n        margin-bottom: 1rem;\n    }\n    \n    .search-suggestions {\n        background: white;\n        border: 1px solid #e2e8f0;\n        border-radius: 8px;\n        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n        margin-bottom: 1rem;\n    }\n    \n    .suggestions-header {\n        padding: 12px 16px;\n        border-bottom: 1px solid #e2e8f0;\n        font-weight: 600;\n        color: #4a5568;\n    }\n    \n    .suggestion-item {\n        display: flex;\n        align-items: center;\n        gap: 8px;\n        padding: 8px 16px;\n        cursor: pointer;\n        transition: background-color 0.2s;\n    }\n    \n    .suggestion-item:hover,\n    .suggestion-active {\n        background-color: #edf2f7;\n    }\n    \n    .search-result {\n        background: white;\n        border: 1px solid #e2e8f0;\n        border-radius: 8px;\n        padding: 1.5rem;\n        margin-bottom: 1rem;\n        transition: box-shadow 0.2s;\n    }\n    \n    .search-result:hover {\n        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n    }\n    \n    .result-title {\n        margin: 0 0 0.5rem 0;\n    }\n    \n    .result-title a {\n        color: #2d3748;\n        text-decoration: none;\n        font-size: 1.2rem;\n    }\n    \n    .result-title a:hover {\n        color: #4299e1;\n    }\n    \n    .result-meta {\n        display: flex;\n        gap: 1rem;\n        margin-bottom: 1rem;\n        font-size: 0.875rem;\n        color: #718096;\n    }\n    \n    .result-description {\n        margin-bottom: 1rem;\n        color: #4a5568;\n        line-height: 1.5;\n    }\n    \n    .result-highlights {\n        background: #fef5e7;\n        border-left: 4px solid #f6ad55;\n        padding: 1rem;\n        margin-bottom: 1rem;\n        font-size: 0.875rem;\n    }\n    \n    .result-highlights mark {\n        background: #fed7d7;\n        padding: 2px 4px;\n        border-radius: 2px;\n    }\n    \n    .result-keywords {\n        display: flex;\n        gap: 0.5rem;\n        flex-wrap: wrap;\n    }\n    \n    .keyword-tag {\n        background: #edf2f7;\n        color: #4a5568;\n        padding: 4px 8px;\n        border-radius: 4px;\n        font-size: 0.75rem;\n    }\n    \n    .loading-state, .error-state, .no-results {\n        text-align: center;\n        padding: 3rem 1rem;\n    }\n    \n    .loading-spinner {\n        width: 40px;\n        height: 40px;\n        border: 4px solid #e2e8f0;\n        border-top: 4px solid #4299e1;\n        border-radius: 50%;\n        animation: spin 1s linear infinite;\n        margin: 0 auto 1rem;\n    }\n    \n    @keyframes spin {\n        0% { transform: rotate(0deg); }\n        100% { transform: rotate(360deg); }\n    }\n    \n    .popular-searches, .search-history {\n        background: white;\n        border: 1px solid #e2e8f0;\n        border-radius: 8px;\n        margin-bottom: 1rem;\n    }\n    \n    .popular-header, .history-header {\n        padding: 12px 16px;\n        border-bottom: 1px solid #e2e8f0;\n        font-weight: 600;\n        color: #4a5568;\n    }\n    \n    .popular-item, .history-item {\n        display: flex;\n        justify-content: space-between;\n        padding: 8px 16px;\n        cursor: pointer;\n        transition: background-color 0.2s;\n    }\n    \n    .popular-item:hover, .history-item:hover {\n        background-color: #edf2f7;\n    }\n    \n    .popular-count {\n        color: #718096;\n        font-size: 0.875rem;\n    }\n`\u003C/span>;\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = { \u003Cspan class=\"hljs-title class_\">MarkdownSearchEngine\u003C/span>, \u003Cspan class=\"hljs-title class_\">AdvancedSearchUI\u003C/span>, searchUIStyles };\n\u003C/code>\u003C/pre>\u003Ch2 id=\"integration-with-modern-documentation-platforms\">Integration with Modern Documentation Platforms\u003C/h2>\n\u003Cp>Search indexing systems integrate seamlessly with comprehensive documentation workflows. When combined with \u003Ca href=\"/blog/markdown-automation-workflows-complete-guide\">automated workflow systems and deployment pipelines\u003C/a>, search indexing becomes part of the continuous integration process, automatically updating search indexes as content is published and ensuring search accuracy across development and production environments.\u003C/p>\n\u003Cp>For sophisticated content management, search systems work effectively with \u003Ca href=\"/blog/markdown-link-management-cross-referencing-complete-guide\">link management and cross-referencing techniques\u003C/a> to create intelligent content discovery platforms where search results leverage existing content relationships and cross-references to provide contextually relevant suggestions and related content recommendations.\u003C/p>\n\u003Cp>When building advanced documentation architectures, search optimization complements \u003Ca href=\"/blog/markdown-form-creation-input-validation-complete-guide\">form systems and user interaction features\u003C/a> by enabling search-driven content creation workflows where user search patterns inform content strategy and form submissions can trigger content updates and search index optimization processes.\u003C/p>\n\u003Ch2 id=\"performance-optimization-strategies\">Performance Optimization Strategies\u003C/h2>\n\u003Ch3 id=\"search-index-optimization\">Search Index Optimization\u003C/h3>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// search-optimization.js - Performance optimization techniques\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">SearchIndexOptimizer\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">searchEngine\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span> = searchEngine;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">performanceMetrics\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStrategies\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeIndex\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Starting index optimization...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Analyze current performance\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentMetrics = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeCurrentPerformance\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Apply optimization strategies\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizations = [\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizeTermFrequencies\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">pruneStopWords\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizeFieldWeights\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">implementIncrementalIndexing\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizeMemoryUsage\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>)\n        ];\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> improvementCount = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> optimize \u003Cspan class=\"hljs-keyword\">of\u003C/span> optimizations) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> result = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">optimize\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (result.\u003Cspan class=\"hljs-property\">improved\u003C/span>) {\n                    improvementCount++;\n                    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`✓ \u003Cspan class=\"hljs-subst\">${result.strategy}\u003C/span>: \u003Cspan class=\"hljs-subst\">${result.improvement}\u003C/span>`\u003C/span>);\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Failed optimization: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizationTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - startTime;\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Optimization completed in \u003Cspan class=\"hljs-subst\">${optimizationTime}\u003C/span>ms (\u003Cspan class=\"hljs-subst\">${improvementCount}\u003C/span> improvements)`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            improvementCount,\n            optimizationTime,\n            \u003Cspan class=\"hljs-attr\">beforeMetrics\u003C/span>: currentMetrics,\n            \u003Cspan class=\"hljs-attr\">afterMetrics\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeCurrentPerformance\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">analyzeCurrentPerformance\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> metrics = {\n            \u003Cspan class=\"hljs-attr\">indexSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateIndexSize\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">searchSpeed\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">benchmarkSearchSpeed\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">memoryUsage\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateMemoryUsage\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">accuracyScore\u003C/span>: \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateAccuracyScore\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> metrics;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">benchmarkSearchSpeed\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> testQueries = [\n            \u003Cspan class=\"hljs-string\">&#x27;markdown tutorial&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;table formatting&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;code blocks&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;link management&#x27;\u003C/span>,\n            \u003Cspan class=\"hljs-string\">&#x27;advanced features&#x27;\u003C/span>\n        ];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> searchTimes = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> query \u003Cspan class=\"hljs-keyword\">of\u003C/span> testQueries) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> startTime = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">search\u003C/span>(query);\n            searchTimes.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - startTime);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">average\u003C/span>: searchTimes.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a + b, \u003Cspan class=\"hljs-number\">0\u003C/span>) / searchTimes.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">min\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(...searchTimes),\n            \u003Cspan class=\"hljs-attr\">max\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(...searchTimes)\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateIndexSize\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Estimate index size based on document count and complexity\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> docs = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>());\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalWords = docs.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, doc\u003C/span>) =&gt;\u003C/span> sum + doc.\u003Cspan class=\"hljs-property\">wordCount\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> uniqueTerms = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>();\n        \n        docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n            doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">_, term\u003C/span>) =&gt;\u003C/span> uniqueTerms.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(term));\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">documents\u003C/span>: docs.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            totalWords,\n            \u003Cspan class=\"hljs-attr\">uniqueTerms\u003C/span>: uniqueTerms.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgTermsPerDoc\u003C/span>: uniqueTerms.\u003Cspan class=\"hljs-property\">size\u003C/span> / docs.\u003Cspan class=\"hljs-property\">length\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateMemoryUsage\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Estimate memory usage\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> docs = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>());\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalSize = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n            totalSize += \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(doc).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">documentsSize\u003C/span>: totalSize,\n            \u003Cspan class=\"hljs-attr\">estimatedIndexSize\u003C/span>: totalSize * \u003Cspan class=\"hljs-number\">1.5\u003C/span>, \u003Cspan class=\"hljs-comment\">// Index overhead\u003C/span>\n            \u003Cspan class=\"hljs-attr\">avgDocSize\u003C/span>: totalSize / docs.\u003Cspan class=\"hljs-property\">length\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeTermFrequencies\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Remove very rare terms that don&#x27;t contribute to search quality\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> termDocCount = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> docs = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>());\n        \n        \u003Cspan class=\"hljs-comment\">// Count document frequency for each term\u003C/span>\n        docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n            doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">_, term\u003C/span>) =&gt;\u003C/span> {\n                termDocCount.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(term, (termDocCount.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(term) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            });\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> minDocFreq = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(\u003Cspan class=\"hljs-number\">1\u003C/span>, docs.\u003Cspan class=\"hljs-property\">length\u003C/span> * \u003Cspan class=\"hljs-number\">0.001\u003C/span>); \u003Cspan class=\"hljs-comment\">// 0.1% threshold\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> termsToRemove = [];\n        \n        termDocCount.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">count, term\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (count &lt; minDocFreq) {\n                termsToRemove.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(term);\n            }\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (termsToRemove.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-comment\">// Remove rare terms from documents\u003C/span>\n            docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n                termsToRemove.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> {\n                    doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(term);\n                });\n            });\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Term frequency optimization&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">improvement\u003C/span>: \u003Cspan class=\"hljs-string\">`Removed \u003Cspan class=\"hljs-subst\">${termsToRemove.length}\u003C/span> rare terms`\u003C/span>\n            };\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>, \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Term frequency optimization&#x27;\u003C/span> };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">pruneStopWords\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Identify and remove domain-specific stop words\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> termFreqGlobal = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> docs = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>());\n        \n        docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n            doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">freq, term\u003C/span>) =&gt;\u003C/span> {\n                termFreqGlobal.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(term, (termFreqGlobal.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(term) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + freq);\n            });\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Find terms that appear in &gt;80% of documents but have low search value\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> highFreqTerms = [];\n        termFreqGlobal.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">freq, term\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (freq &gt; docs.\u003Cspan class=\"hljs-property\">length\u003C/span> * \u003Cspan class=\"hljs-number\">0.8\u003C/span>) {\n                highFreqTerms.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(term);\n            }\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> newStopWords = highFreqTerms.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">term\u003C/span> =&gt;\u003C/span> \n            !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">stopWords\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(term) &amp;&amp; \n            term.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">3\u003C/span> &amp;&amp;\n            \u003Cspan class=\"hljs-regexp\">/^[a-z]+$/\u003C/span>.\u003Cspan class=\"hljs-title function_\">test\u003C/span>(term) \u003Cspan class=\"hljs-comment\">// Only simple words\u003C/span>\n        ).\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">50\u003C/span>); \u003Cspan class=\"hljs-comment\">// Limit additions\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (newStopWords.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            newStopWords.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">stopWords\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(word);\n            });\n            \n            \u003Cspan class=\"hljs-comment\">// Rebuild index to apply new stop words\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildIndex\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Stop word optimization&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">improvement\u003C/span>: \u003Cspan class=\"hljs-string\">`Added \u003Cspan class=\"hljs-subst\">${newStopWords.length}\u003C/span> domain-specific stop words`\u003C/span>\n            };\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>, \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Stop word optimization&#x27;\u003C/span> };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeFieldWeights\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Analyze search performance and adjust field weights\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentWeights = {\n            \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-number\">10\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-number\">5\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">headings\u003C/span>: \u003Cspan class=\"hljs-number\">3\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: \u003Cspan class=\"hljs-number\">8\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">content\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Test different weight combinations\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> testCombinations = [\n            { \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-number\">15\u003C/span>, \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-number\">7\u003C/span>, \u003Cspan class=\"hljs-attr\">headings\u003C/span>: \u003Cspan class=\"hljs-number\">5\u003C/span>, \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: \u003Cspan class=\"hljs-number\">12\u003C/span>, \u003Cspan class=\"hljs-attr\">content\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span> },\n            { \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-number\">8\u003C/span>, \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-number\">4\u003C/span>, \u003Cspan class=\"hljs-attr\">headings\u003C/span>: \u003Cspan class=\"hljs-number\">6\u003C/span>, \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: \u003Cspan class=\"hljs-number\">10\u003C/span>, \u003Cspan class=\"hljs-attr\">content\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span> },\n            { \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-number\">12\u003C/span>, \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-number\">6\u003C/span>, \u003Cspan class=\"hljs-attr\">headings\u003C/span>: \u003Cspan class=\"hljs-number\">2\u003C/span>, \u003Cspan class=\"hljs-attr\">keywords\u003C/span>: \u003Cspan class=\"hljs-number\">15\u003C/span>, \u003Cspan class=\"hljs-attr\">content\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span> }\n        ];\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> bestCombination = currentWeights;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> bestScore = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateAccuracyScore\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> combination \u003Cspan class=\"hljs-keyword\">of\u003C/span> testCombinations) {\n            \u003Cspan class=\"hljs-comment\">// Temporarily update weights and test\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> tempEngine = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createTempEngineWithWeights\u003C/span>(combination);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> score = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateAccuracyScore\u003C/span>(tempEngine);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (score &gt; bestScore) {\n                bestScore = score;\n                bestCombination = combination;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bestCombination !== currentWeights) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">applyFieldWeights\u003C/span>(bestCombination);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Field weight optimization&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">improvement\u003C/span>: \u003Cspan class=\"hljs-string\">`Improved accuracy by \u003Cspan class=\"hljs-subst\">${((bestScore - \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.calculateAccuracyScore()) * \u003Cspan class=\"hljs-number\">100\u003C/span>).toFixed(\u003Cspan class=\"hljs-number\">1\u003C/span>)}\u003C/span>%`\u003C/span>\n            };\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>, \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Field weight optimization&#x27;\u003C/span> };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">calculateAccuracyScore\u003C/span>(\u003Cspan class=\"hljs-params\">engine = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.searchEngine\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Test search accuracy with known good queries\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> testCases = [\n            { \u003Cspan class=\"hljs-attr\">query\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;markdown table&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">expectedInTop5\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;table&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;markdown&#x27;\u003C/span>] },\n            { \u003Cspan class=\"hljs-attr\">query\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;code block syntax&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">expectedInTop5\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;code&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;syntax&#x27;\u003C/span>] },\n            { \u003Cspan class=\"hljs-attr\">query\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;link management&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">expectedInTop5\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;link&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;management&#x27;\u003C/span>] }\n        ];\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalScore = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> testCase \u003Cspan class=\"hljs-keyword\">of\u003C/span> testCases) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">await\u003C/span> engine.\u003Cspan class=\"hljs-title function_\">search\u003C/span>(testCase.\u003Cspan class=\"hljs-property\">query\u003C/span>, { \u003Cspan class=\"hljs-attr\">maxResults\u003C/span>: \u003Cspan class=\"hljs-number\">5\u003C/span> });\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> topTitles = results.\u003Cspan class=\"hljs-property\">results\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">r\u003C/span> =&gt;\u003C/span> r.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>());\n            \n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> score = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> expected \u003Cspan class=\"hljs-keyword\">of\u003C/span> testCase.\u003Cspan class=\"hljs-property\">expectedInTop5\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (topTitles.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">title\u003C/span> =&gt;\u003C/span> title.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(expected))) {\n                    score += \u003Cspan class=\"hljs-number\">1\u003C/span>;\n                }\n            }\n            \n            totalScore += score / testCase.\u003Cspan class=\"hljs-property\">expectedInTop5\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> totalScore / testCases.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">implementIncrementalIndexing\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Implement incremental indexing to improve update performance\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span> = {\n                \u003Cspan class=\"hljs-attr\">enabled\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">lastUpdate\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n                \u003Cspan class=\"hljs-attr\">pendingUpdates\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>()\n            };\n            \n            \u003Cspan class=\"hljs-comment\">// Add method to update single document\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">updateDocument\u003C/span> = \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-keyword\">function\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> doc = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processDocument\u003C/span>(filePath);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(doc.\u003Cspan class=\"hljs-property\">id\u003C/span>, doc);\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span>.\u003Cspan class=\"hljs-property\">lastUpdate\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(doc.\u003Cspan class=\"hljs-property\">id\u003C/span>, \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>());\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span>.\u003Cspan class=\"hljs-property\">pendingUpdates\u003C/span>.\u003Cspan class=\"hljs-title function_\">add\u003C/span>(doc.\u003Cspan class=\"hljs-property\">id\u003C/span>);\n                }\n                \n                \u003Cspan class=\"hljs-comment\">// Rebuild index if too many pending updates\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span>.\u003Cspan class=\"hljs-property\">pendingUpdates\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span> &gt; \u003Cspan class=\"hljs-number\">50\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildIndex\u003C/span>();\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">incrementalIndexing\u003C/span>.\u003Cspan class=\"hljs-property\">pendingUpdates\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n                }\n                \n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> doc;\n            };\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Incremental indexing&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">improvement\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Enabled incremental document updates&#x27;\u003C/span>\n            };\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>, \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Incremental indexing&#x27;\u003C/span> };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeMemoryUsage\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Optimize memory usage by compressing stored data\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> docs = \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">searchEngine\u003C/span>.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>());\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> compressionSavings = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        docs.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">doc\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Remove redundant data\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> originalSize = \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(doc).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Compress term frequencies (keep only significant ones)\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> significantTerms = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> threshold = \u003Cspan class=\"hljs-number\">1\u003C/span> / doc.\u003Cspan class=\"hljs-property\">wordCount\u003C/span> * \u003Cspan class=\"hljs-number\">0.01\u003C/span>; \u003Cspan class=\"hljs-comment\">// 1% threshold\u003C/span>\n            \n            doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span>.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">freq, term\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (freq &gt; threshold) {\n                    significantTerms.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(term, \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(freq * \u003Cspan class=\"hljs-number\">1000\u003C/span>) / \u003Cspan class=\"hljs-number\">1000\u003C/span>); \u003Cspan class=\"hljs-comment\">// Round to 3 decimals\u003C/span>\n                }\n            });\n            \n            doc.\u003Cspan class=\"hljs-property\">termFrequency\u003C/span> = significantTerms;\n            \n            \u003Cspan class=\"hljs-comment\">// Limit sentence storage\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">sentences\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">20\u003C/span>) {\n                doc.\u003Cspan class=\"hljs-property\">sentences\u003C/span> = doc.\u003Cspan class=\"hljs-property\">sentences\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">20\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Limit key phrases\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">keyPhrases\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">15\u003C/span>) {\n                doc.\u003Cspan class=\"hljs-property\">keyPhrases\u003C/span> = doc.\u003Cspan class=\"hljs-property\">keyPhrases\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">15\u003C/span>);\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> newSize = \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(doc).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            compressionSavings += originalSize - newSize;\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (compressionSavings &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Memory optimization&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">improvement\u003C/span>: \u003Cspan class=\"hljs-string\">`Reduced memory usage by \u003Cspan class=\"hljs-subst\">${(compressionSavings / \u003Cspan class=\"hljs-number\">1024\u003C/span>).toFixed(\u003Cspan class=\"hljs-number\">1\u003C/span>)}\u003C/span>KB`\u003C/span>\n            };\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">improved\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>, \u003Cspan class=\"hljs-attr\">strategy\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Memory optimization&#x27;\u003C/span> };\n    }\n}\n\u003C/code>\u003C/pre>\u003Ch2 id=\"conclusion\">Conclusion\u003C/h2>\n\u003Cp>Advanced Markdown search indexing and optimization systems represent a sophisticated approach to content discovery that transforms static documentation into intelligent, searchable knowledge bases capable of understanding user intent and delivering contextually relevant results. By implementing comprehensive search indexing strategies, semantic analysis techniques, and performance optimization methods, organizations can build powerful search experiences that help users find information quickly while maintaining excellent performance across large content repositories.\u003C/p>\n\u003Cp>The key to successful search implementation lies in balancing search accuracy with performance, ensuring that advanced features serve user needs without compromising system responsiveness. Whether you&#39;re building technical documentation, knowledge management systems, or content-heavy websites, the techniques covered in this guide provide the foundation for creating robust search experiences that scale effectively with your content growth.\u003C/p>\n\u003Cp>Remember to continuously monitor search performance metrics, analyze user search patterns to identify content gaps and optimization opportunities, and regularly update your indexing strategies based on content evolution and user behavior patterns. With proper implementation of advanced search indexing and optimization techniques, your Markdown-based content can deliver exceptional discovery experiences that help users navigate complex information landscapes efficiently and intuitively.\u003C/p>\n",[15,19,22,25,28],{"id":16,"text":17,"level":18},"why-master-markdown-search-indexing","Why Master Markdown Search Indexing?",2,{"id":20,"text":21,"level":18},"foundation-search-architecture","Foundation Search Architecture",{"id":23,"text":24,"level":18},"integration-with-modern-documentation-platforms","Integration with Modern Documentation Platforms",{"id":26,"text":27,"level":18},"performance-optimization-strategies","Performance Optimization Strategies",{"id":29,"text":30,"level":18},"conclusion","Conclusion",[],[33,41,49],{"slug":34,"title":35,"description":36,"excerpt":37,"date":38,"category":9,"author":10,"keywords":39,"readingMinutes":40},"markdown-table-data-filtering-search-complete-guide","Markdown Table Data Filtering and Search: Complete Guide for Interactive Content Discovery and Dynamic Data Navigation","Master table data filtering and search capabilities in Markdown for enhanced content discovery. Learn JavaScript integration, advanced filtering techniques, and responsive search implementations for interactive documentation.","Table data filtering and search capabilities in Markdown enable dynamic content discovery that transforms static tabular information into interactive, searchable interfaces allowing users to…","2025-12-16","markdown table filtering, table search functionality, interactive markdown tables, data filtering markdown, table javascript integration, searchable tables markdown, dynamic table filtering, markdown table navigation",30,{"slug":42,"title":43,"description":44,"excerpt":45,"date":46,"category":9,"author":10,"keywords":47,"readingMinutes":48},"markdown-text-wrapping-line-length-management-guide","Markdown Text Wrapping and Line Length Management: Complete Guide for Document Formatting and Content Optimization","Master Markdown text wrapping techniques, line length management, and content formatting for optimal readability across different platforms. Learn hard wraps, soft wraps, line break strategies, and automated formatting approaches.","Advanced Markdown text wrapping and line length management techniques enable professional document formatting that optimizes content readability across different platforms and display…","2025-11-06","markdown text wrapping, markdown line length, text formatting markdown, markdown hard wrap, markdown soft wrap, line breaks markdown, markdown paragraph formatting, content optimization",19,{"slug":50,"title":51,"description":52,"excerpt":53,"date":54,"category":9,"author":10,"keywords":55,"readingMinutes":56},"markdown-performance-optimization-best-practices-complete-guide","Markdown Performance Optimization and Best Practices: Complete Guide for High-Performance Documentation Systems","Master advanced Markdown performance optimization techniques for fast-loading documentation, efficient parsing, and scalable content systems. Learn caching strategies, asset optimization, and performance monitoring for Markdown-based sites.","Advanced Markdown performance optimization and best practices enable high-performance documentation systems that deliver exceptional user experiences while maintaining scalability across large…","2025-11-24","markdown performance optimization, markdown best practices, documentation performance, markdown parsing optimization, static site performance, markdown caching, content delivery optimization, markdown asset management",28,1792184943896]