# Example Code for Exporting Data from Elasticsearch Index to Google Sheets via Apps Script

**URL:** <https://discuss.elastic.co/t/example-code-for-exporting-data-from-elasticsearch-index-to-google-sheets-via-apps-script/368223>\
**Category:** Elasticsearch\
**Created:** [October 3, 2024, 9:26pm UTC](https://discuss.elastic.co/t/example-code-for-exporting-data-from-elasticsearch-index-to-google-sheets-via-apps-script/368223 "2024-10-03T21:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thanyasit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thanyasit/32/137946_2.png) [@Thanyasit](https://discuss.elastic.co/u/Thanyasit)\
**Post date:** [October 3, 2024, 9:26pm UTC](https://discuss.elastic.co/t/example-code-for-exporting-data-from-elasticsearch-index-to-google-sheets-via-apps-script/368223/1 "2024-10-03T21:26:01Z")

</div>

Hi All, I I'm currently trying to export data from an Elasticsearch index into Google Sheets using Google Apps Script, but I'm having difficulty with the integration. Specifically, I'm looking for an example script that:

1. Connects to an Elasticsearch endpoint (via basic authentication).
2. Queries the Elasticsearch index using filters and aggregations.
3. Exports the data from the query results and writes it into a Google Sheet.

---

<div class="post-metadata">

**Author:** ![nfeekery](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nfeekery/32/117349_2.png) [@nfeekery](https://discuss.elastic.co/u/nfeekery)\
**Post date:** [October 4, 2024, 8:56am UTC](https://discuss.elastic.co/t/example-code-for-exporting-data-from-elasticsearch-index-to-google-sheets-via-apps-script/368223/2 "2024-10-04T08:56:06Z")

</div>

From #Elastic Search to #Elasticsearch

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2024, 8:56am UTC](https://discuss.elastic.co/t/example-code-for-exporting-data-from-elasticsearch-index-to-google-sheets-via-apps-script/368223/3 "2024-11-01T08:56:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
