Why don't you try and read some research papers on this topic and then decide how you would want to build your algorithm? Some links -
http://static.googleusercontent.com/media/research.google.co...
http://insight-centre.org/sites/default/files/publications/1...
http://users.cis.fiu.edu/~taoli/pub/p125-li-sigir2011.pdf
http://arxiv.org/pdf/1303.0665v2.pdf
http://scholarworks.sjsu.edu/cgi/viewcontent.cgi?article=129...
https://www.ntnu.no/wiki/download/attachments/71733389/WEBIS...
A chapter dedicated to the subject -