diff --git a/frappe/patches/v8_0/update_records_in_global_search.py b/frappe/patches/v8_0/update_records_in_global_search.py index 8ee8f36de8..4792ebec5a 100644 --- a/frappe/patches/v8_0/update_records_in_global_search.py +++ b/frappe/patches/v8_0/update_records_in_global_search.py @@ -1,7 +1,11 @@ import frappe from frappe.utils.global_search import get_doctypes_with_global_search, rebuild_for_doctype +from frappe.utils import update_progress_bar def execute(): frappe.cache().delete_value('doctypes_with_global_search') - for doctype in get_doctypes_with_global_search(with_child_tables=False): + doctypes_with_global_search = get_doctypes_with_global_search(with_child_tables=False) + + for i, doctype in enumerate(doctypes_with_global_search): + update_progress_bar("Updating Global Search", i, len(doctypes_with_global_search)) rebuild_for_doctype(doctype) diff --git a/frappe/utils/global_search.py b/frappe/utils/global_search.py index 7271118f4c..9d2aa0f51c 100644 --- a/frappe/utils/global_search.py +++ b/frappe/utils/global_search.py @@ -182,13 +182,16 @@ def insert_values_for_multiple_docs(all_contents): values.append("( '{doctype}', '{name}', '{content}', '{published}', '{title}', '{route}')" .format(**content)) - # ignoring duplicate keys for doctype_name - frappe.db.sql(''' - insert ignore into __global_search - (doctype, name, content, published, title, route) - values - {0} - '''.format(", ".join(values))) + batch_size = 50000 + for i in range(0, len(values), batch_size): + batch_values = values[i:i + batch_size] + # ignoring duplicate keys for doctype_name + frappe.db.sql(''' + insert ignore into __global_search + (doctype, name, content, published, title, route) + values + {0} + '''.format(", ".join(batch_values))) def update_global_search(doc):