Why do you need to change it? You can re-implement the search component or overlay it and change the reference to com.day.cq.wcm.foundation.Search to a reference to your own class.
Thanks for you reply,
I need to modify a couple of methods, the biggest change is to change the output to JSON.
I'm new the CQ and I don't know what the best thing to do is to extend this class. Is there a particular location where you would put the new class and it automatically gets registered? or do you have to register it yourself and then it doesn't matter where it lives?.....
Should I extend it or is it better to copy all together and modify?
The point is that the class could change with future releases and break your extension. Assuming that you find a way to extend.
If you need a custom search you can easily implement your own one as Jörg said.