Fix indexing error with empty documents