[英]Why Python not returning True after connecting ElasticSearch Server
I have connected to Elastic Search(ES) with below code, but its not returning True. 我已使用以下代码连接到Elastic Search(ES),但其未返回True。 http://localhost:9200/ is giving proper output 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"
The Python Code 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)
I am trying to execute from the URL http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/ 我正在尝试从URL http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/执行
I have tested your code from the blog. 我已经从博客测试了您的代码。 Its working fine. 它的工作正常。 I uploaded in the github also 我也上传了github
https://github.com/mak705/Python_ELK/blob/master/recipie.ipynb https://github.com/mak705/Python_ELK/blob/master/recipie.ipynb
Courtesy : Adnan who wrote the blog http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/ 礼貌:写博客http://blog.adnansiddiqi.me/getting-started-with-elasticsearch-in-python/的 Adnan
NB: In latest version of ES(6,x) we don't need to mention mapping tags that is starting from the mapping { . 注意:在最新版本的ES(6,x)中,我们不需要提及从映射{开始的映射标签。 Its automatically detects and give the schema. 它会自动检测并给出架构。 In earlier version(5.x) we have to mention the schema 在早期版本(5.x)中,我们不得不提及架构
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.