I have connected to Elastic Search(ES) with below code, but its not returning True. http://localhost:9200/ is giving proper output
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
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/
I have tested your code from the blog. Its working fine. I uploaded in the github also
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/
NB: In latest version of ES(6,x) we don't need to mention mapping tags that is starting from the mapping { . Its automatically detects and give the schema. In earlier version(5.x) we have to mention the schema
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.