title: Limit the Elasticsearch results count in Rails
body: <p>I'm running Rails with Elasticsearch using the elasticsearch-rails and will_paginate gems and things are working great.</p>
  
  <p>The only problem I'm having is that my records count has grown over 10.000 which gives the error "Result window is too large, from + size must be less than or equal to: [10000] but was [10200]" when someone clicks on the last page of the pagination links.</p>
  
  <p>Now I don't want to mess with index.max_result_window because my dataset is going be much much larger and I really don't need visitors to be able to view every page and record anyway.</p>
  
  <p>So basically I just want to set a limit of 10.000 on my results but I'm having no luck getting that working.</p>
  
  <p>This is the query I have in my controller action:</p>
  
  <pre><code>@response = Price.search(params)
  @response = @response.paginate(page: params[:page], per_page: 24)
  @prices = @response.records.includes(shop: :pictures)
  @prices_count = @response.total_entries
  @prices = @prices.decorate
  @results = @response.results
  </code></pre>
  
  <p>And I feed the @response to will_paginate using</p>
  
  <pre><code>will_paginate(@response)
  </code></pre>
  
  <p>I've tried using .limit(10000) in various places and giving a total_entries value to will_paginate but nothing seems to work.</p>
  
  <p>Do you guys have any ideas?</p>
  
  <p>Thanks!</p>