First round at refactoring Search.controller.php

Signed-off-by: emanuele <emanuele45@gmail.com>