Added defQuery option to search api

Closes #251 

@steveoh Would you mind reviewing?