Fix SQL error when all apps are searchable.

#4551