Python 嗖声索引错误:写入程序已关闭

Python 嗖声索引错误:写入程序已关闭,python,whoosh,Python,Whoosh,我正在使用代码,并且收到错误消息 这位作家已经关门了 我正在使用whoosh和python。我从一个json文件中获取数据,然后使用循环进行迭代,以创建搜索引擎索引 从whoosh.fields导入架构、文本、ID 从whoosh进口指数 从whoosh.qparser导入QueryParser 导入操作系统路径 导入json 如果不存在os.path.exists(“indexdir”): os.mkdir(“indexdir”) schema=schema(标题=TEXT(存储=True),

我正在使用代码,并且收到错误消息

这位作家已经关门了

我正在使用whoosh和python。我从一个json文件中获取数据,然后使用循环进行迭代,以创建搜索引擎索引

从whoosh.fields导入架构、文本、ID
从whoosh进口指数
从whoosh.qparser导入QueryParser
导入操作系统路径
导入json
如果不存在os.path.exists(“indexdir”):
os.mkdir(“indexdir”)
schema=schema(标题=TEXT(存储=True),内容=TEXT(存储=True))
ix=索引。在(“indexdir”,模式)中创建
doc_json=json.load(打开(“review.json”,'r'))
对于doc_json中的文档:
将ix.writer()作为w:
对于键,doc.get('properties').items()中的值:
w、 添加文档(title=str(key),content=str(值[0]。get('value'))
w、 提交()
w.commit()关闭写入程序,因此您可以这样做:

with ix.writer() as w:
    for doc in doc_json:
        for key,value in doc.get('properties').items():
            w.add_document(title=str(key), content=str(value[0].get('value')))
    w.commit()

请发布实际错误。文件“/usr/local/lib/python2.7/dist packages/whoosh/filedb/filewriting.py”,第179行,处于“检查”状态,引发索引错误(“此编写器已关闭”)whoosh.writing.IndexingError:此编写器已关闭。欢迎!我试图改进你的问题。进一步参考:@PrakherAgarwal发布问题中的错误,而不是评论。