from fastapi import APIRouter from app.clickhouse import get_client from app.schemas import CompanySearchQuery router = APIRouter(prefix="/companies", tags=["companies"]) @router.post("/search") def search_companies(payload: CompanySearchQuery): client = get_client() result = client.query( "SELECT name, domain, country FROM companies WHERE name ILIKE {q:String} LIMIT {limit:UInt32}", parameters={"q": f"%{payload.query}%", "limit": payload.limit}, ) return {"results": result.result_rows}