我已使用以下代码连接到Elastic Search(ES),但未返回True。 http://localhost:9200/正在提供正确的输出
name "0jDPVkL"
cluster_name "elasticsearch"
cluster_uuid "9PfIve-HSP-v7kU__DbGmQ"
version
number "6.4.1"
build_flavor "default"
build_type "zip"
build_hash "e36acdb"
build_date "2018-09-13T22:18:07.696808Z"
build_snapshot false
lucene_version "7.4.0"
minimum_wire_compatibility_version "5.6.0"
minimum_index_compatibility_version "5.0.0"
tagline "You Know, for Search"
Python代码
import logging
def connect_elasticsearch():
_es = None
_es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
if _es.ping():
print('Yay Connect')
else:
print('Awww it could not connect!')
return _es
if __name__ == '__main__':
logging.basicConfig(level=logging.ERROR)
我正在尝试从URL http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/
执行答案 0 :(得分:0)
我已经通过博客测试了您的代码。它的工作正常。我也上传了github
https://github.com/mak705/Python_ELK/blob/master/recipie.ipynb
礼貌:写博客http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/
的阿德南(Adnan)NB:在最新版本的ES(6,x)中,我们不需要提及从映射{开头的映射标签。它会自动检测并给出架构。在早期版本(5.x)中,我们不得不提及架构