'python'에 해당되는 글 21건

  1. 2023.07.29 Elastic Search Python 연결
2023. 7. 29. 18:38

설치: 설치가 가장 어려움

현재 Elastic Search를 6버전으로 설치해서, pip에서도 6버전으로 다운로드가 필요함...

 

elasticsearch6        6.8.2
elasticsearch6-dsl    6.4.0

 

위의 버전을 pip install로 설치하면 됨(버전 생략가능)

 

from datetime import datetime
# from collections import Mapping
from elasticsearch6 import Elasticsearch
es = Elasticsearch("http://localhost:9200")

# doc = {
#     'author': 'kimchi',
#     'text': 'Elasticsearch: cool bossam kimchi',
#     'timestamp': datetime.now(),
# }

es.indices.create(index='my-index', ignore=400)

# resp = es.index(index="my-index", doc_type="test_type", id=42, body=doc)
# print(resp['result'])
print(es.get(index="my-index", doc_type="test_type", id=42))

 

 

외국 예제인데, 한국 김치가 역시 세계적이긴 한가봄

갑자기 보쌈 김치가 먹고 싶어짐...

Posted by 다만사