Ini cuplikan singkat saya:
$user_query = preg_replace("/[[:blank:]]+/"," ", $user_query);
$arr_query = explode(' ', $user_query);
if (count($arr_query) > 1) {
$tmp = array();
foreach ($arr_query as $q) {
$tmp[] = new MongoRegex( "/". $q ."/" );
}
$who['keywords'] = array('$in' => $tmp);
} else {
$who['keywords'] = new MongoRegex( "/". $user_query ."/" );
}
$db->collection->find( $who );