chore: Add query clean-up
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py
index b004f80..c6f04df 100644
--- a/erpnext/templates/pages/product_search.py
+++ b/erpnext/templates/pages/product_search.py
@@ -67,6 +67,8 @@
red = frappe.cache()
+ query = clean_up_query(query)
+
ac = AutoCompleter(make_key(WEBSITE_ITEM_NAME_AUTOCOMPLETE), conn=red)
client = Client(make_key(WEBSITE_ITEM_INDEX), conn=red)
suggestions = ac.get_suggestions(query, num=10)
@@ -75,7 +77,7 @@
query_string = query
for s in suggestions:
- query_string += f"|('{s.string}')"
+ query_string += f"|('{clean_up_query(s.string)}')"
q = Query(query_string)
@@ -88,6 +90,9 @@
return results
+def clean_up_query(query):
+ return ''.join(c for c in query if c.isalnum() or c.isspace())
+
def convert_to_dict(redis_search_doc):
return redis_search_doc.__dict__