main entry function for search

support cache of a query object