# Query an index an put it into another index in Ingest plugin

**URL:** <https://discuss.elastic.co/t/query-an-index-an-put-it-into-another-index-in-ingest-plugin/119379>\
**Category:** Elasticsearch\
**Created:** [February 11, 2018, 3:16pm UTC](https://discuss.elastic.co/t/query-an-index-an-put-it-into-another-index-in-ingest-plugin/119379 "2018-02-11T15:16:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrigui94](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@chrigui94](https://discuss.elastic.co/u/chrigui94)\
**Post date:** [February 11, 2018, 3:16pm UTC](https://discuss.elastic.co/t/query-an-index-an-put-it-into-another-index-in-ingest-plugin/119379/1 "2018-02-11T15:16:20Z")

</div>

I need to copy fields from an index to another one using an ingest plugin. I have used the following query:  
SearchResponse response = client.prepareSearch("index1", "index2")  
.setTypes("type1", "type2")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.termQuery("multi", "test")) // Query  
.setPostFilter(QueryBuilders.rangeQuery("age").from(12).to(18)) // Filter  
.setFrom(0).setSize(60).setExplain(true)  
.get();

In the new index I can see the fields added in it but the problem that ES increase the number of documents in the new index continuously but in reality, I have to found the same number of documents of the original index.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 11, 2018, 4:24pm UTC](https://discuss.elastic.co/t/query-an-index-an-put-it-into-another-index-in-ingest-plugin/119379/2 "2018-02-11T16:24:08Z")

</div>

It's super unclear...

How this query is related to the reindex operation?  
How is it related to an ingest plugin? Which one?

Then I'm not sure I'm understanding this part:

> but the problem that ES increase the number of documents in the new index continuously but in reality, I have to found the same number of documents of the original index.

And finally, please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

---

<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 11, 2018, 4:24pm UTC](https://discuss.elastic.co/t/query-an-index-an-put-it-into-another-index-in-ingest-plugin/119379/3 "2018-03-11T16:24:17Z")

</div>

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