Both the comments gadget and ratings gadget can be scoped to an "ID".
As long as you can uniquely associate a search result with an "ID",
you should be able to simply display a comments gadget or ratings
gadget with a corresponding ID and it should just work. I'd recommend
generating IDs by taking the SHA1 hash of the search query and using
that as the ID — that way you don't need to keep a database mapping of
queries -> IDs.