I am using the code, and I am getting as error message
This writer is closed
I am using whoosh and python. I am fetching data from a json file and I then iterate with a loop for creating the search engine index.
from whoosh.fields import Schema,TEXT,ID
from whoosh import index
from whoosh.qparser import QueryParser
import os.path
import json
if not os.path.exists("indexdir"):
os.mkdir("indexdir")
schema = Schema(title=TEXT(stored=True), content=TEXT(stored=True))
ix = index.create_in("indexdir", schema)
doc_json=json.load(open("review.json",'r'))
for doc in doc_json:
with ix.writer() as w:
for key,value in doc.get('properties').items():
w.add_document(title=str(key), content=str(value[0].get('value')))
w.commit()