Fix crash when searching without a document