Also add a reindex endpoint and button to rebuild the Meilisearch index from files already on disk, without needing to re-upload them.
18 lines
511 B
Python
18 lines
511 B
Python
from fastapi import APIRouter, Depends
|
|
|
|
from app.dependencies import get_document_service, get_search_client
|
|
from app.document_service import DocumentService
|
|
from app.search_client import SearchClient
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/api/search")
|
|
def search(q: str = "", client: SearchClient = Depends(get_search_client)):
|
|
return {"results": client.search(q)}
|
|
|
|
|
|
@router.post("/api/search/reindex")
|
|
def reindex(service: DocumentService = Depends(get_document_service)):
|
|
return service.reindex_all()
|