From 91d0e47f1dacf544533dc840b848cb5a59646a6a Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 17 Jun 2020 20:03:38 +0530 Subject: [PATCH 01/56] feat: optimize while storing index --- frappe/modules/full_text_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/modules/full_text_search.py b/frappe/modules/full_text_search.py index fce9983907..a9b93a1265 100644 --- a/frappe/modules/full_text_search.py +++ b/frappe/modules/full_text_search.py @@ -67,7 +67,7 @@ def build_index(index_name, documents): title=document.title, path=document.path, content=document.content ) - writer.commit() + writer.commit(optimize=True) def search(index_name, text, scope=None, limit=20): From aa0cf2bad4ba4a0ed749e0187bab7f39fcb5cd92 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 17 Jun 2020 20:05:08 +0530 Subject: [PATCH 02/56] feat: added re-index method --- frappe/modules/full_text_search.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frappe/modules/full_text_search.py b/frappe/modules/full_text_search.py index a9b93a1265..d06d925d08 100644 --- a/frappe/modules/full_text_search.py +++ b/frappe/modules/full_text_search.py @@ -101,6 +101,26 @@ def search(index_name, text, scope=None, limit=20): return out +def reindex_path(index_name, path): + document = get_document_to_index(path): + reindex(index_name, document) + +def reindex(index_name, document): + index_dir = get_index_path(index_name) + ix = open_dir(index_dir) + + with ix.searcher() as searcher: + writer = ix.writer() + + # Remove the index of the particular file + writer.delete_by_term('path', document.path) + + # that wasn't indexed before. So index it! + writer.add_document( + title=document.title, path=document.path, content=document.content + ) + + writer.commit(optimize=True) def get_index_path(index_name): return frappe.get_site_path("indexes", index_name) From d5d32770136fc71e6d0de8bbc3a291b825d916a0 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 17 Jun 2020 20:05:55 +0530 Subject: [PATCH 03/56] feat: move search portable --- frappe/templates/doc.html | 66 +-------------------------- frappe/website/js/website.js | 86 +++++++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 65 deletions(-) diff --git a/frappe/templates/doc.html b/frappe/templates/doc.html index 3e1cc5509a..1c70aace98 100644 --- a/frappe/templates/doc.html +++ b/frappe/templates/doc.html @@ -22,7 +22,7 @@
-