I think @Ranjan is asking how Discourse implements search in the Discourse application and is not asking about Google search.
He seems interested to understand how Discourse implements their internal search algorithm, and a good place to start is here in class SearchController:
Hey @Ranjan … you would be amazed at how much information can be found in the Discourse open source code on GitHub!