From 9db450f815b18090ca9f04d01e68d541a7bd6f4e Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 17 Jun 2020 20:47:03 +0530 Subject: [PATCH] feat: add remove index option --- frappe/modules/full_text_search.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frappe/modules/full_text_search.py b/frappe/modules/full_text_search.py index 7ccc68f877..022200f3cc 100644 --- a/frappe/modules/full_text_search.py +++ b/frappe/modules/full_text_search.py @@ -120,5 +120,17 @@ def reindex(index_name, document): writer.commit(optimize=True) +def remove_from_index(index_name, path): + # open index + index_dir = get_index_path(index_name) + ix = open_dir(index_dir) + + # initiate search scope to find previous index + with ix.searcher() as searcher: + writer = ix.writer() + + # Remove the index of the particular file + writer.delete_by_term('path', path) + def get_index_path(index_name): return frappe.get_site_path("indexes", index_name)