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: