mirror of
https://github.com/simon987/od-database.git
synced 2025-04-10 14:06:45 +00:00
27 lines
506 B
Python
27 lines
506 B
Python
import ujson
|
|
|
|
from search.search import ElasticSearchEngine
|
|
|
|
es = ElasticSearchEngine("od-database")
|
|
es.reset()
|
|
|
|
with open("dump.json", "r") as f:
|
|
|
|
buffer = list()
|
|
index_every = 10000
|
|
|
|
for line in f:
|
|
try:
|
|
doc = ujson.loads(line)["_source"]
|
|
buffer.append(doc)
|
|
|
|
if len(buffer) >= index_every:
|
|
es._index(buffer)
|
|
buffer.clear()
|
|
|
|
except Exception as e:
|
|
print("ERROR: " + str(e))
|
|
|
|
es._index(buffer)
|
|
|