Quickstart
Install
Section titled “Install”uv add lexigram-searchFor a specific backend, install with extras:
# MeiliSearch (default)uv add "lexigram-search[meilisearch]"# Elasticsearchuv add "lexigram-search[elasticsearch]"# PostgreSQL full-textuv add "lexigram-search[postgres]"# All backendsuv add "lexigram-search[search-all]"Minimal Example
Section titled “Minimal Example”import asyncio
from lexigram import Application, LexigramConfigfrom lexigram.search import SearchProvider, SearchConfigfrom lexigram.search.config import BackendType
async def main(): config = LexigramConfig.from_yaml("application.yaml") app = Application(name="my-app", config=config) app.add_provider(SearchProvider.with_memory())
async with app.boot(): # Resolve the search engine from lexigram.contracts.search import SearchEngineProtocol
engine = await app.container.resolve(SearchEngineProtocol)
# Index a document await engine.index_document("doc-1", {"title": "Hello world", "content": "Lexigram search works"})
# Search result = await engine.search("hello") print(f"Found {result.total} result(s)") for hit in result.results: print(f" - {hit.data['title']} (score: {hit.score})")
asyncio.run(main())Wiring
Section titled “Wiring”Add SearchProvider to your Application. The provider auto-discovers SearchConfig from the search: section of your YAML config:
from lexigram.search import SearchProvider
app.add_provider(SearchProvider.configure(SearchConfig( backend_type=BackendType.MEILISEARCH,)))Or use the declarative SearchModule:
from lexigram.search import SearchModulefrom lexigram.search.config import SearchConfig
app.add_module(SearchModule.configure(SearchConfig(backend_type="meilisearch")))Next Steps
Section titled “Next Steps”- Guide — mental model, core concepts, best practices
- Configuration — every config key with defaults and env vars
- How-Tos — common recipes