Improved search query processing

Search queries are cleared properly (the to field wasn't being included previously)
Only clear project/user if they were previously set on empty query

Change-Id: Ife64879a633eaca47f1ea69f6e1f9d2631062856