A query log parser can be written to detect spam. At first you can use cookies (e.g. sessions) and IP-addresses to detect term spam. You can also limit a popularity spike to a reasonable mean size over a longer period. And you can limit rates using logarithms.
There are many ways to deal with spam and maintain decent statistics. In practice, it's not a big problem on most sites. > Ranking suggestions based on query count would be trivially easy to spam. > Have a bot make my preferred queries over and over again, and "boom" they > are the most-preferred.