There are two ways to unit test the controller, but it will require some changes for you.
The first is to unit test the controller itself, without adding the complexity of http parsing, so you would write your unit test and pass in the params.query as part of your unit test, so, split your search function into two functions:
def search = {
def query = params.query
render realSearch(query) as JSON
}
def realSearch ...
So, the first part tests realSearch
.
Then the second part is to write an application that will actually connect to your web application, and do a functional test, which will test your entire application, including the parts of the controller that wasn't tested in the first part.