If you are interested in looking at how search is implemented in Frappe, have a look here and here Frappe uses python library Whoosh, it is an open-source, pure Python search engine library which stores its index in a file system.
frappe.utils.global_search
in Frappe Framework allows you to perform full text search on any doctype using a custom FullTextSearch class. It uses a third-party library called Whoosh, which is a full text search library written in Python. The code for implementing frappe.utils.global_search is in the global_search.py file of Frappe Framework.