Согласно коду вчерашнего поста, вы можете попробовать создать дамп es из базы данных oracle:
class CreateDump(object):
def __init__():
self.output = r"/home/littlely/Scrivania/oracle_dump.json"
self.index_name = "your_index_name"
self.doc_type = "your_doc_type"
def _gen_data(self, index, doc_type, chunk_size):
sql = """select * from tem_search_engine_1 where rownum <= 10000"""
self.cursor.execute(sql)
col_name_list = [col[0].lower() for col in self.cursor.description]
col_name_len = len(col_name_list)
actions = []
start = time.time()
for row in self.cursor:
source = {}
tbl_id = ""
for i in range(col_name_len):
source.update({col_name_list[i]: str(row[i])})
if col_name_list[i] == "tbl_id":
tbl_id = row[i]
self.writeOnFS(source, tbl_id)
def writeOnFS(source, tbl_id):
with open(self.output, 'a') as f:
prep = json.dumps({"index":{"_index" : self.index_name, "_type" : self.doc_type, "_id" : tbl_id}})
data = json.dumps(source)
print(data)
f.write(prep + " \n")
f.write(data + " \n")
Тогда вы найдете свалку оракула в self.output
пути. Таким образом, вам нужно только объединить ваш файл в формате json - двоичный путь - это путь self.output:
curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/<your_index_name>/<your_doc_type)/_bulk --data-binary @/home/littlely/Scrivania/oracle_dump.json
ИЛИ если он слишком большой, установите GNU PARAllEl. В Ubuntu:
sudo apt-get install parallel
и затем:
cat /home/littlely/Scrivania/oracle_dump.json.json | parallel --pipe -L 2 -N 2000 -j3 'curl -H "Content-Type: application/x-ndjson" -s http://localhost:9200/<your_index_name>/_bulk --data-binary @- > /dev/null'
Наслаждайтесь!