mirror of
https://github.com/simon987/od-database.git
synced 2025-12-14 07:09:03 +00:00
Change ES settings, big refactor, removed recaptcha
This commit is contained in:
25
restore.py
Normal file
25
restore.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from search.search import ElasticSearchEngine
|
||||
import ujson
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user