db: Limit the size of autocomplete tables

Impose a 1000 row limit on the number of autocomplete suggestions.

Issue #316.
db: Use text frequencies to determine ac suggestions

Issue #316.
db: Refactor autocomplete logic for cleanliness

Issue #316.
Merge branch 'issue/316'