@ngao/search-core
v1.0.1
Published
Lightweight search engine library for code and documentation
Maintainers
Readme
@ngao/search-core
Lightweight search engine library for indexing and searching code, documentation, and text.
Features
- 🔍 Full-text search with ranking
- 🧠 Semantic search with embeddings
- 📝 Multi-language support (Python, JavaScript, TypeScript, Markdown, JSON, YAML)
- ⚡ Fast incremental indexing
- 💾 LanceDB vector database
- 📦 Zero external service dependencies
Installation
npm install @ngao/search-corePre-downloaded Models (Included)
Important: This library uses pre-downloaded local embedding models, NOT npm downloads.
The embedding models are included in the package at models/ directory:
@ngao/search-core/
├── dist/
├── models/ ← Pre-downloaded models included here
│ └── Xenova/
│ └── all-MiniLM-L6-v2/
│ ├── config.json
│ ├── tokenizer.json
│ ├── tokenizer_config.json
│ └── onnx/
│ └── model_quantized.onnx
└── package.jsonFor Development:
# If models are missing, download them:
cd ngao-search-core
mkdir -p models/Xenova
git clone https://huggingface.co/Xenova/all-MiniLM-L6-v2 models/Xenova/all-MiniLM-L6-v2The library automatically detects and uses these pre-downloaded models. Benefits:
- ✅ No npm download overhead - models bundled with package
- ✅ Works offline after installation
- ✅ Faster initialization (~50ms vs ~5s download)
- ✅ Self-contained library with all dependencies
Quick Start
import { SearchEngine } from '@ngao/search-core'
const engine = new SearchEngine()
await engine.indexDirectory('./src')
const results = await engine.search('useContext')
results.forEach(result => {
console.log(`${result.filePath}:${result.location.startLine} - ${result.name}`)
})API Overview
SearchEngine
The main interface for indexing and searching.
interface ISearchEngine {
indexDirectory(dirPath: string): Promise<IndexStats>
indexFile(filePath: string): Promise<void>
reindexFile(filePath: string): Promise<void>
search(query: string): Promise<SearchResult[]>
getIndexStats(): Promise<IndexStats>
}Types
Block- A searchable code/documentation blockSearchResult- A search hit with relevance scoreQuery- Parsed search queryIndexStats- Index statistics
Documentation
License
Apache-2.0
