Fixes internal server error in advanced search

Part of OOIION-1413
Merge pull request #62 from Bobfrat/advSearchErr-r2

Fixes internal server error in advanced search