Skip to content

Commit 35ec65c

Browse files
committed
added support for 'DD' parameter in FT.DEL command
1 parent 582efc3 commit 35ec65c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

API.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Create the search index. The index must not already exist.
283283
### delete\_document
284284
```py
285285

286-
def delete_document(self, doc_id, conn=None)
286+
def delete_document(self, doc_id, conn=None, delete_actual_document=False)
287287

288288
```
289289

@@ -292,6 +292,9 @@ def delete_document(self, doc_id, conn=None)
292292
Delete a document from index
293293
Returns 1 if the document was deleted, 0 if not
294294

295+
### Parameters
296+
297+
- **delete_actual_document**: if set to True, RediSearch also delete the actual document if it is in the index
295298

296299
### drop\_index
297300
```py

redisearch/client.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,22 @@ def add_document_hash(
337337
doc_id, conn=None, score=score, language=language, replace=replace,
338338
)
339339

340-
def delete_document(self, doc_id, conn=None):
340+
def delete_document(self, doc_id, conn=None, delete_actual_document=False):
341341
"""
342342
Delete a document from index
343343
Returns 1 if the document was deleted, 0 if not
344+
345+
### Parameters
346+
347+
- **delete_actual_document**: if set to True, RediSearch also delete the actual document if it is in the index
344348
"""
349+
args = [self.DEL_CMD, self.index_name, doc_id]
345350
if conn is None:
346351
conn = self.redis
352+
if delete_actual_document:
353+
args.append('DD')
347354

348-
return conn.execute_command(self.DEL_CMD, self.index_name, doc_id)
355+
return conn.execute_command(*args)
349356

350357
def load_document(self, id):
351358
"""

0 commit comments

Comments
 (0)