Вопрос

This strange error appears after i had interrupted whoosh commit process. When i am trying to commit now i'm getting

  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

I've tried to reinstall lib, change the index directory but it doesn't work. So how could i repair whoosh?

Это было полезно?

Решение

I think there is no need to "repair whoosh" (or the index).

It might be simply your code that opens a writer, uses it maybe, closes it and then tries to use the closed writer again.

Just always do it like that:

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!")

And if you need to add more documents later (outside this "with"-block), open a new writer the same way...

Note: the writer w gets automatically closed when leaving the with-block, that's how a so-called context manager works.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top