You don't need to grab injector and $state.go, not at all. The argument to otherwise
method can be a URL path, which can contain parameters in it.
So in your particular case, following code can lead you to base_url/search?query=x
$urlRouterProvider.otherwise("/search?query=x");
Alternatively, the argument can be a function that returns a URL path. If you are not sure what URL parameters it could have, you just need to get the parameters from $location
then format to the URL-like string and return it.
$urlRouterProvider.otherwise(function($injector, $location) {
var params = $location.search()
// format params to 'p1=v1&p2=v2' style
var formatted = Object.keys(params).map(function(key) {
return key + '=' + params[key]
}).join('&')
return '/search?' + formatted
});