Null check on Lucene documents, fix documents search query