Fixes internal server error in advanced search

Part of OOIION-1413