ElasticSearch 连接

启用 ElasticSearch 集成的 ElasticSearch 连接。

ElasticSearch 认证

使用 ElasticSearch DBAPI 进行认证

默认连接 ID

一些与 ElasticSearch 相关的 hook 和 operator 默认使用 elasticsearch_default。

配置连接

用户

指定用于初始连接的登录名

密码

指定用于初始连接的 Elasticsearch API 密钥

主机

指定用于初始连接的 Elasticsearch 主机

端口

指定用于初始连接的 Elasticsearch 端口

方案

指定 Elasticsearch API 的方案。默认为 http

Extra (可选)

指定可在 Elasticsearch 连接中使用的额外参数(JSON 字典格式)。以下参数均为可选

  • http_compress: 指定是否使用 http_compress。默认为 False。

  • timeout: 指定 timeout 的时限。默认为 False。

在环境变量中指定连接时,应使用 URI 语法指定。

注意,URI 的所有组件都应进行 URL 编码。

例如

export AIRFLOW_CONN_ELASTICSEARCH_DEFAULT='elasticsearch://elasticsearchlogin:elasticsearchpassword@elastic.co:80/http'

tests/system/elasticsearch/example_elasticsearch_query.py

es = ElasticsearchSQLHook(elasticsearch_conn_id=CONN_ID)

es_connection = es.get_conn()
response = es_connection.execute_sql("SHOW TABLES")
for row in response["rows"]:
    print(f"row: {row}")
return True

此条目有帮助吗?