Use the same code for both search view and search api.