Fix queries for postgresql and fix some bugs on search events controller

(ActionItem2587)

Signed-off-by: Marcos Ramos <ms.ramos@outlook.com>
Signed-off-by: Carlos Andre <carlos.andre.souza@msn.com>