build prefix search method