"Any body know which classes will be useful"
Pretty much all of them.
"how to achieve this?"
Start by working for Google, or Bing and expect to be promoted big time if you manage it...
There has been a huge amount of time and money spent on this problem:
Google[
^] and I'm not convince there is a "good" solution yet - all the ones I've seen are pretty language specific...
This is not an easy task, and there is no easy solution - or we wouldn't have to use SQL queries at all...