Redistribute documents with custom routing and reindex API


(Thomas Decaux) #1

I have an index with 3 shards, with default routing.

Now, I want to use a custom route (let says field "userID").

How can I use _reindex API to achieve this?

Thanks you,

PS: I saw there is a routing options for reindex API, but it seems you cannot specify document field in it ;/


(Nik Everett) #2

You can do it with scripts. It'd look something like:

POST _reindex
{
  "source": {
    "index": "old"
  },
  "dest": {
    "index": "new"
  },
  "script": {
    "inline": "ctx._routing = doc.whatever.value"
  }
}

(system) #3

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