New to Kestra?
Use blueprints to kickstart your first workflows.
Query an Elasticsearch index with the ESQL API and load the CSV results into a pandas DataFrame in Python, orchestrated end to end by Kestra.
Query an Elasticsearch index with the ESQL API and turn the results into a pandas DataFrame, all in one declarative Kestra flow. This blueprint bridges the gap between search and data science: instead of exporting data by hand, copying CSV files, or wiring up a notebook against your cluster, you run an ESQL statement, stream the CSV response straight into a Python script, and start working with the data as a DataFrame. It is a clean pattern for analytics, reporting, data validation, and feeding downstream machine learning or transformation steps from your Elasticsearch documents.
The flow chains two tasks that run in sequence:
esql_query task (io.kestra.plugin.elasticsearch.Request) connects to your Elastic Cloud cluster over HTTPS using an API key passed through the Authorization header. It sends a POST to the /_query?format=csv endpoint with an ESQL body (FROM test | WHERE title IS NOT NULL), so Elasticsearch returns the matching rows already formatted as CSV.pandas task (io.kestra.plugin.scripts.python.Script) receives that CSV through inputFiles as data.csv, bound to {{ outputs.esql_query.response }}. It installs the pandas dependency, reads the file with pd.read_csv, and prints data.head() so you can immediately inspect the result.pandas already declared as a dependency.Elasticsearch is a search and analytics engine, not a scheduler or workflow tool: it cannot trigger your Python script, retry a failed query, or track which run produced which DataFrame. Kestra fills that gap. You can attach event or schedule triggers to run the query on new data, add retries on transient cluster or network errors, and get full execution lineage from the query response to the Python output. The whole pipeline stays declarative YAML, versioned and reviewable, instead of a script that lives on someone's laptop.
pandas.ES_API_TOKEN: the Elasticsearch API key used in the Authorization: ApiKey ... header.ES_API_TOKEN secret to your Kestra instance.hosts value to point at your own Elasticsearch cluster.query and the FROM test index to match your data.pandas task logs for the printed DataFrame head.print(data.head()) with real transformations, aggregations, or feature engineering.