search: Factor out a function
search: Match an empty array, not a null one

When the terms are missing, we pass an empty array, not a null one.
search: Reset the search display when there's no search terms

Destroy the previous search view when there's no search terms, to make
sure old search items don't show up.