2013-01-21 66 views
1

這個奇怪的錯誤出現在我中斷了whoosh commit過程之後。當我試圖現在提交我越來越python whoosh中斷IndexingError

File "/usr/local/lib/python2.7/dist-packages/whoosh/filedb/filewriting.py", line 179, in  _check_state 
    raise IndexingError("This writer is closed") 
whoosh.writing.IndexingError: This writer is closed 

我試圖重新安裝lib,更改索引目錄,但它不起作用。那麼我怎麼修復whoosh?

回答

1

我認爲沒有必要「修復whoosh」(或索引)。

它可能只是您的代碼,打開一個作家,也許使用它,關閉它,然後再次嘗試使用封閉的作家。

就一直那樣做:

with myindex.writer() as w: 
    w.add_document(title=u"First document", content=u"Hello there.") 
    w.add_document(title=u"Second document", content=u"This is easy!") 

如果你需要在以後添加更多的文件(超出此「與」 - 塊),打開一個新的作家以同樣的方式...

注意:編寫器w在離開with-block時會自動關閉,這就是所謂的上下文管理器的工作原理。