# How to reindex a data stream into another data stream?

**URL:** <https://discuss.elastic.co/t/how-to-reindex-a-data-stream-into-another-data-stream/383131>\
**Category:** Elasticsearch\
**Tags:** reindex, datastreams\
**Created:** [October 31, 2025, 4:10pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-data-stream-into-another-data-stream/383131 "2025-10-31T16:10:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dot-mike](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dot-mike/32/143339_2.png) [@dot-mike](https://discuss.elastic.co/u/dot-mike)\
**Post date:** [October 31, 2025, 4:10pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-data-stream-into-another-data-stream/383131/1 "2025-10-31T16:10:43Z")

</div>

Hi community,

I’m trying to reindex data from one data stream to another.

Basically, I want data from this data stream `logs-syslog.myproduct.logs` to go into `logs-syslog.myproduct_logs-default`

The issue is that when the original data stream was created, I used ``logs`` as the namespace. I now want to move the data to the `default` namespace instead.

I tried the reindex request:

```auto
POST _reindex
{
  "source": {
    "index": ".ds-logs-syslog.myproduct-logs-2025.08.16-000004",
  },
  "dest": {
    "index": "logs-syslog.myproduct_logs-default",
    "pipeline": "_none",
    "op_type": "create"
  },
  "conflicts": "proceed"
}

```

However, I’m getting the following error for all documents:

```auto
    {
      "index": ".ds-logs-syslog.myproduct-logs-2025.08.16-000004",
      "id": "bIPpTZkBpFzTMhyAGyn-",
      "cause": {
        "type": "document_parsing_exception",
        "reason": "[1:1062] failed to parse field [data_stream.namespace] of type [constant_keyword] in document with id 'bIPpTZkBpFzTMhyAGyn-'. Preview of field's value: 'logs'",
        "caused_by": {
          "type": "illegal_argument_exception",
          "reason": "[constant_keyword] field [data_stream.namespace] only accepts values that are equal to the value defined in the mappings [default], but got 
[logs]"
        }
      },
      "status": 400
    },

```

Has anyone run into this before? What’s the proper way to reindex documents into a new data stream with a different namespace & name of the datastream it-self is different?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [October 31, 2025, 5:04pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-data-stream-into-another-data-stream/383131/2 "2025-10-31T17:04:21Z")

</div>

You need to change `data_stream.namespace` from `logs` to `default` to be able to index in the new data stream.

I think you can do that using a script in the reindex.

Something like this:

```auto
POST _reindex
{
  "source": {
    "index": ".ds-logs-syslog.myproduct-logs-2025.08.16-000004",
  },
  "script": {
    "source":"ctx._source.data_stream.namespace = 'default'",
    "lang":"painless"
  },
  "dest": {
    "index": "logs-syslog.myproduct_logs-default",
    "pipeline": "_none",
    "op_type": "create"
  },
  "conflicts": "proceed"
}

```

---

<div class="post-metadata">

**Author:** ![dot-mike](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dot-mike/32/143339_2.png) [@dot-mike](https://discuss.elastic.co/u/dot-mike)\
**Post date:** [November 3, 2025, 2:02pm UTC](https://discuss.elastic.co/t/how-to-reindex-a-data-stream-into-another-data-stream/383131/3 "2025-11-03T14:02:06Z")

</div>

Many thanks! It worked with the script parameter. A few notes:

if you see any issues, add the `?error_trace=true` parameter to the url: `POST _reindex?error_trace=true`

in my case I also had to change `data_stream.dataset` and there two properties that need to be changed for the dataset. So this is the script I used below. With this all is working well! **I hope one day maybe Elastic will add option in the UI to move data to another namespace / datastream.**

```auto
"script": {
"lang": "painless",
"source": """
ctx._source.data_stream.dataset = ‘syslog.myproduct_logs';
ctx._source.data_stream.namespace = 'default';
ctx._source.event.dataset = 'syslog.myproduct_logs';
"""
}

```
