validate queries before executing them

This ensures that at least one trigram is queried in the index, which
prevents very short queries (e.g. “1”) or even empty queries that made
it past the stop-gap length filter because they were using a keyword
(e.g. “1 path:debian”).