Reindex with text replace

I was trying to reindex a large index when I discovered that there are trailing \r\n in the end of all values of a field. Since the mapping in the new index for this field is a double, and not a string, it crashes.

How do I replace/trim these values to in the reindex process?

If all you want to do is trim whitespace on the one field, you can set up an ingest pipeline with the trim processor set up for the field, then specify the pipeline in your reindex request like so:

POST _reindex
{
  "source": {
    "index": "source_index"
  },
  "dest": {
    "index": "dest_index",
    "pipeline": "trim_my_double_field_pipeline"
  }
}

(above example pulled with minor changes from the Reindex docs)

Alternatively, you could use a script in the reindex request, but using an ingest pipeline is probably easier.

Thank you Gordon!

It works! And I learned something...

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