Due to the use of the temp table xf_search_index_temp, only one search can be done per php session. A simple $db->query('drop table if exists `xf_search_index_temp`'); before the create statement would fix this.