delete_points endpoint
This commit is contained in:
parent
6dda8ac74c
commit
a0efd90c14
41
src/app.py
41
src/app.py
@ -140,6 +140,47 @@ def add():
|
||||
|
||||
|
||||
|
||||
@app.post("/delete_points")
|
||||
def delete_points():
|
||||
if request.content_type == 'application/json':
|
||||
try:
|
||||
data = request.get_json(force=True)
|
||||
if data is None:
|
||||
raise BadRequest
|
||||
except BadRequest:
|
||||
return jsonify({"error": "Invalid JSON"}), 400
|
||||
else:
|
||||
|
||||
data = request.form.to_dict()
|
||||
|
||||
doc_uuid=data.get("doc_uuid")
|
||||
if not doc_uuid:
|
||||
return jsonify({"error": "Missing 'doc_uuid' in request"}), 400
|
||||
filter_condition = models.Filter(
|
||||
must=[
|
||||
models.FieldCondition(
|
||||
key="doc_id",
|
||||
match=models.MatchValue(value=doc_uuid)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
try:
|
||||
result = Qdrant.get_client().delete(
|
||||
|
||||
points_selector=models.FilterSelector(
|
||||
filter=filter_condition
|
||||
),
|
||||
wait=True
|
||||
)
|
||||
if result and result.status == "completed":
|
||||
return jsonify({"message": f"Deleted all points with doc_id = {doc_uuid}"}), 200
|
||||
else:
|
||||
return jsonify({"warning": "Deletion request did not complete successfully"}), 500
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.post("/delete")
|
||||
def delete():
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user