# Curator: possible to "reindex by query"?

**URL:** <https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081>\
**Category:** Elasticsearch\
**Created:** [March 21, 2018, 9:50pm UTC](https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081 "2018-03-21T21:50:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rozling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rozling/32/16401_2.png) [@rozling](https://discuss.elastic.co/u/rozling)\
**Post date:** [March 21, 2018, 9:50pm UTC](https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081/1 "2018-03-21T21:50:15Z")

</div>

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 😕

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [March 21, 2018, 10:32pm UTC](https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081/2 "2018-03-21T22:32:25Z")

</div>

[It is possible](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/option_request_body.html#_other_scenarios_and_options). You just need to convert the JSON to YAML. [Here](https://www.json2yaml.com/) 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.

---

<div class="post-metadata">

**Author:** ![rozling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rozling/32/16401_2.png) [@rozling](https://discuss.elastic.co/u/rozling)\
**Post date:** [March 22, 2018, 3:45pm UTC](https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081/3 "2018-03-22T15:45:42Z")

</div>

Excellent! Worked like a charm - thanks Aaron.

---

<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:** [April 19, 2018, 3:45pm UTC](https://discuss.elastic.co/t/curator-possible-to-reindex-by-query/125081/4 "2018-04-19T15:45:43Z")

</div>

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