Fixes internal server error in advanced search

Part of OOIION-1413
Merge pull request #66 from Bobfrat/advSearchError

Fixes internal server error in advanced search