airflow.providers.elasticsearch.hooks.elasticsearch

Module Contents

Classes

ESConnection

wrapper class for elasticsearch.Elasticsearch.

ElasticsearchSQLHook

Interact with Elasticsearch through the elasticsearch-dbapi.

ElasticsearchHook

This class is deprecated and was renamed to ElasticsearchSQLHook.

ElasticsearchPythonHook

Interacts with Elasticsearch. This hook uses the official Elasticsearch Python Client.

Functions

connect([host, port, user, password, scheme])

airflow.providers.elasticsearch.hooks.elasticsearch.connect(host='localhost', port=9200, user=None, password=None, scheme='http', **kwargs)[source]
class airflow.providers.elasticsearch.hooks.elasticsearch.ESConnection(host='localhost', port=9200, user=None, password=None, scheme='http', **kwargs)[source]

wrapper class for elasticsearch.Elasticsearch.

class airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchSQLHook(schema='http', connection=None, *args, **kwargs)[source]

Bases: airflow.providers.common.sql.hooks.sql.DbApiHook

Interact with Elasticsearch through the elasticsearch-dbapi.

This hook uses the Elasticsearch conn_id.

Parameters

elasticsearch_conn_id – The ElasticSearch connection id used for Elasticsearch credentials.

conn_name_attr = 'elasticsearch_conn_id'[source]
default_conn_name = 'elasticsearch_default'[source]
conn_type = 'elasticsearch'[source]
hook_name = 'Elasticsearch'[source]
get_conn()[source]

Return an elasticsearch connection object.

get_uri()[source]

Extract the URI from the connection.

Returns

the extracted uri.

Return type

str

class airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchHook(*args, **kwargs)[source]

Bases: ElasticsearchSQLHook

This class is deprecated and was renamed to ElasticsearchSQLHook.

Please use airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchSQLHook.

class airflow.providers.elasticsearch.hooks.elasticsearch.ElasticsearchPythonHook(hosts, es_conn_args=None)[source]

Bases: airflow.hooks.base.BaseHook

Interacts with Elasticsearch. This hook uses the official Elasticsearch Python Client.

Parameters
  • hosts (list[Any]) – list: A list of a single or many Elasticsearch instances. Example: [“http://localhost:9200”]

  • es_conn_args (dict | None) – dict: Additional arguments you might need to enter to connect to Elasticsearch. Example: {“ca_cert”:”/path/to/cert”, “basic_auth”: “(user, pass)”}

get_conn()[source]

Return the Elasticsearch client (cached).

search(query, index='_all')[source]

Return results matching a query using Elasticsearch DSL.

Parameters
  • index (str) – str: The index you want to query

  • query (dict[Any, Any]) – dict: The query you want to run

Returns

dict: The response ‘hits’ object from Elasticsearch

Return type

dict

Was this entry helpful?