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/
retry_on_timeout=TruetoElasticsearchinit