Moodle is not setting it - it must be set by the server for some reason. Very rarely I've seen things like this ... I have a fix planned for Moodle 2.0.
In the meantime, here is a quick fix: edit the script, look for this line near the top:
change it to:
$search = empty($_POST['search']) ? "" : $_POST['search'] ;