search: Rework and use classes

Signed-off-by: Fam Zheng <famz@redhat.com>