Fix parentheses in Solr boolean operator query

Solr does not interpret AND and OR the same way mathematics does, and
needs parentheses. See
http://www.mail-archive.com/java-user@lucene.apache.org/msg00008.html
for more information.

This adds in the parentheses, without regressing by adding them around a
query with a LocalParam (http://wiki.apache.org/solr/LocalParams), which
is invalid.