title: Using scroll api via elasticsearch-model
body: <p>For the life of me I can't find any reference to using the ElasticSearch scroll api from within Ruby on Rails and the elastisearch-model (or rails or dsl) gem.</p>
  
  <p>The only thing they do reference in the docs is calling scroll directly on the client, which kind of defeats the purpose. Also, it does not use the client or any client settings you've already set in your Rails app.</p>
  
  <p>I want to do something like this.</p>
  
  <p>Here is the ElasticSearch query that works from within the Kibana Dev Tools:</p>
  
  <pre><code>GET model_index/_search?scroll=1m
        {
          "size": 100,
          "query": {
            "match": {
              "tenant_id": 3196
            }
          },
          "_source": "id"
        }
  </code></pre>
  
  <p>I would have thought that I could call something like</p>
  
  <pre><code>MyModel.search scroll: '1m', ...
  </code></pre>
  
  <p>but instead it seems like I need to do:</p>
  
  <pre><code># First create a client by hand
  client = Elasticssearch::Client.new    
  result = client.search index: 'model_index',
  scroll: '1m',
  body: { query: { match: { tenant_id: 3196 } }, sort: '_id' }
  </code></pre>
  
  <p>Does anyone have any more user-friendly examples?</p>