# Reindex: how to limit number of docs for testing:

**URL:** <https://discuss.elastic.co/t/reindex-how-to-limit-number-of-docs-for-testing/257137>\
**Category:** Elasticsearch\
**Tags:** reindex\
**Created:** [November 30, 2020, 10:48pm UTC](https://discuss.elastic.co/t/reindex-how-to-limit-number-of-docs-for-testing/257137 "2020-11-30T22:48:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [November 30, 2020, 10:48pm UTC](https://discuss.elastic.co/t/reindex-how-to-limit-number-of-docs-for-testing/257137/1 "2020-11-30T22:48:06Z")

</div>

I am having problem getting reindex to do what I want and the indexes I have available for testing have over 100,000 docs and when things fail this is 100.000 tracebacks in the logs!

I see from the docs that there is a max\_docs parameter under query options but no example of use so I have assumed that the search is associated with the source and tried this:

```auto

  def do_reindex( name = nil, new_name = nil)
    params = { source: { index: name || @name }, target: { index: new_name || @options[:new_name]} }
    params[:script] = @options[:script] if @options[:script]
    if @options[:max_docs]
      params[:source][:query] = { max_docs: @options[:max_docs] }
    end
    pp params

   @client.reindex( params )
end

```

prints:

```auto
there are 1 indices in authx_2019.09.02 to reindex
{:source=>{:index=>"authx_2019.09.02", :query=>{:max_docs=>10}},
 :target=>{:index=>"authentication_2019.09.02"}}
warning: 299 Elasticsearch-7.10.0-51e9d6f22758d0374a0f3f5c6e8f3a7997850f96 "[types removal] Specifying types in bulk requests is deprecated."
warning: 299 Elasticsearch-7.10.0-51e9d6f22758d0374a0f3f5c6e8f3a7997850f96 "[types removal] Specifying types in bulk requests is deprecated."

```

BTW ruby api converts the ruby hash into json.

If the max\_docs was set up correctly it would need only one bulk operation.

---

<div class="post-metadata">

**Author:** ![Russell\_Fulton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russell_fulton/32/62888_2.png) [@Russell\_Fulton](https://discuss.elastic.co/u/Russell_Fulton)\
**Post date:** [December 1, 2020, 6:44pm UTC](https://discuss.elastic.co/t/reindex-how-to-limit-number-of-docs-for-testing/257137/2 "2020-12-01T18:44:14Z")

</div>

I suspect this is an issue with the ruby binding for the api and have logged an issue on the github repository. After a but of experimentation I discovered I could add any thing I liked to the source and target hashes and they would be completely ignored -- ie no errors for garbage.

Further confirmation is that it works when I do the request from ruby with an http post directly.

---

<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:** [December 29, 2020, 6:44pm UTC](https://discuss.elastic.co/t/reindex-how-to-limit-number-of-docs-for-testing/257137/3 "2020-12-29T18:44:14Z")

</div>

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