Add additional query validation to the terms query parser

Fixes #2608