Other terms in topN query

This patch adds optional support for "other terms" in topN query. Closes #654.