import asyncio
from dot_search import SearchEngine, TableConfig, EmbeddingConfig


async def main():
    engine = SearchEngine(db_url="postgresql+asyncpg://user:pass@localhost/mydb")

    # Index — config saved to ds_configs
    await engine.index(config=TableConfig(
        table="documents",
        embeddings=[EmbeddingConfig(source_column="body", target_column="ds_body")],
    ))

    # Search
    results = await engine.search("neural networks", "documents", limit=5)
    for r in results:
        print(r)


asyncio.run(main())
