Curator: possible to "reindex by query"?

So the reindex api lets you reindex a subset of your data using a search query:

POST _reindex
{
  "source": {
    "index": "twitter",
    "type": "tweet",
    "query": {
      "term": {
        "user": "kimchy"
      }
    }
  },
  "dest": {
    "index": "new_twitter"
  }
}

However I'm having trouble finding out if this is possible with Curator. Ideally I'd like to use the Curator Python API (want to reindex a bunch of stuff with -1 suffixes and then delete the originals), and in the docs I found this reference:

request_body – The body to send to elasticsearch.Elasticsearch.reindex(), which must be complete and usable, as Curator will do no vetting of the request_body. If it fails to function, Curator will return an exception.

request_body looks something like this:

  request_body:
    source:
      index: REINDEX_SELECTION
    dest:
      index: logstash-myindex-2018.01.18-1

but I can't find any documentation for Elasticsearch requests in this YAML format :confused:

It is possible. You just need to convert the JSON to YAML. Here is one such potential tool.

Just remember that everything under source in the JSON will need to be nested under source in the YAML.

I'm not quite sure what happens with REINDEX_SELECTION in conjunction with a query, but it should just work.

Excellent! Worked like a charm - thanks Aaron.

1 Like

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