# Looking for an alternative to reindex and collapse

**URL:** <https://discuss.elastic.co/t/looking-for-an-alternative-to-reindex-and-collapse/219173>\
**Category:** Elasticsearch\
**Created:** [February 13, 2020, 9:38am UTC](https://discuss.elastic.co/t/looking-for-an-alternative-to-reindex-and-collapse/219173 "2020-02-13T09:38:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andni233](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andni233](https://discuss.elastic.co/u/andni233)\
**Post date:** [February 13, 2020, 9:38am UTC](https://discuss.elastic.co/t/looking-for-an-alternative-to-reindex-and-collapse/219173/1 "2020-02-13T09:38:18Z")

</div>

Hello!

I have an index that contains a lot of "raw" data, around 40.000 documents.

I want to refine this data a bit, and store the refined data in a different index. For this purpose, I came up with this search query to find the documents that I want to store in the other index:

```
{
    "query": {"match": {"Selector": "selector"}},
    "collapse": {
        "field": "Identifier",
        "inner_hits": {
            "name": "document_to_reindex",
            "size": 1,
            "sort": [{"FirstTimestmap": "desc"}, {"SeocndTimestamp": "desc"}],
        },
    },
}

```

This works and gives me the documents I need.

When I want to move the search results to the other index, I figure I would make use of the reindex API. However, this does not work with the above query as it uses collapse. My second though was to fetch the data to a computer somewhere using the above query and then upload it to the new index from there. This does not work due to the search hitting more than 10.000 documents.

Do you have any advice on how I can proceed with this issue? Can collapse be used for this task?

---

<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:** [March 12, 2020, 9:38am UTC](https://discuss.elastic.co/t/looking-for-an-alternative-to-reindex-and-collapse/219173/2 "2020-03-12T09:38:19Z")

</div>

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