python + elasticsearch api
ELK/elasticsearch2019. 1. 29. 08:58
from elasticsearch import Elasticsearch, exceptions
class Elas:
def __init__(self):
self.esnode = None
def ElasticServSetting(self):
try:
self.esnode = Elasticsearch(hosts="192.168.240.129", port="9200")
except exceptions.ConnectionError as e:
print (e)
else:
settings= {
"settings": {
"number_of_shards": 3
},
"mappings": {
"doc": {
"properties": {
"numb" : {"type": "integer"},
"name" : {"type": "text"}
}
}
}
}
# create index
self.esnode.indices.create(index="indx190128", ignore=400, body=settings)
def main():
node = Elas() # 객체 생성
node.ElasticServSetting()l
if __name__ == "__main__":
main()
'ELK > elasticsearch' 카테고리의 다른 글
python + elasticsearch + 조회/삽입/생성 (0) | 2019.02.03 |
---|---|
search java api (0) | 2019.01.29 |
java api elasticsearch aggregation (0) | 2019.01.28 |
java api2 (0) | 2019.01.25 |
java api (0) | 2019.01.25 |