ElasticsearchPythonHook¶
Elasticsearch Hook that is using the native Python client to communicate with Elasticsearch
Parameters¶
- hosts
A list of a single or many Elasticsearch instances. Example:
["http://localhost:9200"]
.- es_conn_args
Additional arguments you might need to enter to connect to Elasticsearch. Example:
{"ca_cert":"/path/to/cert", "basic_auth": "(user, pass)"}
For all possible configurations, consult with Elasticsearch documentation. Reference: https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/connecting.html
Usage Example¶
def use_elasticsearch_hook():
"""
Use ElasticSearchPythonHook to print results from a local Elasticsearch
"""
es_hosts = ["http://localhost:9200"]
es_hook = ElasticsearchPythonHook(hosts=es_hosts)
query = {"query": {"match_all": {}}}
result = es_hook.search(query=query)
print(result)
return True