# How to export forecast data into a destination index

**URL:** https://discuss.elastic.co/t/how-to-export-forecast-data-into-a-destination-index/279380
**Category:** Elasticsearch
**Tags:** elastic-stack-machine-learning
**Created:** [July 22, 2021, 12:30pm UTC](https://discuss.elastic.co/t/how-to-export-forecast-data-into-a-destination-index/279380 "2021-07-22T12:30:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![StephaneB](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@StephaneB](https://discuss.elastic.co/u/StephaneB)
#### Post date: [July 22, 2021, 12:30pm UTC](https://discuss.elastic.co/t/how-to-export-forecast-data-into-a-destination-index/279380/1 "2021-07-22T12:30:42Z")

</div>

Hello,

I'm currently using API to create job, datafeed and associated forecast in order to determine if some predicted values will exceed a specific threshold in the next weeks:

- if no value exceeds the threshold then I delete the job (with its associated datafeed and forecast)
- if some values exceed the threshold then I would like to export all the forecast documents into a specific index before deleting the job (with its associated datafeed and forecast).

I can retreive all the forecast data by using the following search and then copy all the forecast documents in a destination index (with a loop on hits).

```auto
GET .ml-anomalies*/_search
{
  "query": {
    "bool" :{
      "filter": [
        { 
          "query_string":{
            "query": "result_type:model_forecast",
            "analyze_wildcard": true
          }
        },
        {"term": { "job_id": "job_on_device1"}},
        {"term": { "forecast_id": "Gwn4wnoB0F2uUBpmgO6V"}}]
    }
  }
}

```

But, is there another way to export forecast documents to a specific index?

---

<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: [August 19, 2021, 12:31pm UTC](https://discuss.elastic.co/t/how-to-export-forecast-data-into-a-destination-index/279380/2 "2021-08-19T12:31:23Z")

</div>

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