Local Search¶
Use Lean Explore with a local backend for offline access and faster queries.
Setup¶
Fetch Local Data¶
First, download the necessary data files:
This downloads: - SQLite database with declarations - FAISS index for semantic search - Embedding model files - ID mapping files
Verify Data¶
Check that data is available:
Using Local Backend¶
CLI¶
Python API¶
from lean_explore.local.service import Service
# Initialize local service
service = Service()
# Search
results = await service.search("natural numbers")
# Process results
for item in results.results:
print(item.primary_declaration.lean_name)
HTTP Server¶
Then query via HTTP:
Configuration¶
Custom Data Directory¶
Custom Database URL¶
from lean_explore.local.service import Service
service = Service(
db_url="sqlite:///path/to/database.db"
)
Advantages of Local Backend¶
- Offline Access: No internet connection required
- Faster Queries: No network latency
- Privacy: Data stays on your machine
- No API Key: No authentication needed
- Customizable: Full control over data and configuration
Data Updates¶
To update your local data:
This will download the latest data files.
Storage Location¶
By default, data is stored in:
- macOS/Linux: ~/.leanexplore/data
- Windows: %APPDATA%\leanexplore\data
Next Steps¶
- CLI Usage - Command-line interface
- API Client - Python API client
- HTTP Server - HTTP API server