mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-07-23 08:52:16 +00:00

* Add rest api endpoint to delete documents by filter. * Remove parametrization of rest api tests * Make the paths in rest_api/config.py absolute * Fix path to pipelines.yaml * Restructuring test_rest_api.py to be able to test only my endpoint (and to make the suite more structured) * Convert DELETE /documents into POST /documents/delete_by_filters Co-authored by: sarthakj2109 <54064348+sarthakj2109@users.noreply.github.com>
26 lines
705 B
Python
26 lines
705 B
Python
import logging
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from rest_api.application import DOCUMENT_STORE
|
|
from rest_api.config import LOG_LEVEL
|
|
from rest_api.schema import FilterRequest
|
|
|
|
|
|
logging.getLogger("haystack").setLevel(LOG_LEVEL)
|
|
logger = logging.getLogger("haystack")
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post("/documents/delete_by_filters", response_model=bool)
|
|
def delete_documents(filters: FilterRequest):
|
|
"""
|
|
Can be used to delete documents from a document store.
|
|
|
|
:param filters: Filters to narrow down the documents to delete.
|
|
Example: {"name": ["some", "more"], "category": ["only_one"]}
|
|
"""
|
|
DOCUMENT_STORE.delete_documents(filters=filters.filters)
|
|
return True |