rewrite parse_search_params() fn to use plpgsql