added a printquery function that dumps final query
fixed incorrect search_value for global search