forked from rene4jazz/visimil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelasticsearch_init.py
executable file
·38 lines (29 loc) · 971 Bytes
/
elasticsearch_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import json
import os
import sys
from elasticsearch import Elasticsearch
if __name__ == "__main__":
# if os.environ.get('ES_HOSTS'):
# ELASTICSEARCH_HOSTS = \
# [{'host': es_host, 'port': 9200}
# for es_host in os.environ.get('ES_HOSTS').split(",")]
# else:
# ELASTICSEARCH_HOSTS = None
# try:
# if ELASTICSEARCH_HOSTS:
# es = Elasticsearch(ELASTICSEARCH_HOSTS)
# else:
# raise Exception
# except Exception as e:
# print(e)
# sys.exit(1)
ELASTICSEARCH_HOSTS = [{'host': "127.0.0.1", 'port': 9200}]
es = Elasticsearch(ELASTICSEARCH_HOSTS)
flist = range(512)
fields = {}
for f in flist:
fields["F" + str(f)] = {"type": "double"}
request_body = {'mappings': {'image': {'properties': fields}}}
print("Initializing elasticsearch")
es.indices.create(index='visimil', body=request_body, ignore=400)