title: Pagination in Elasticsearch PHP
body: <p>I have an array in Elasticsearch which returns 400 records:</p>
  
  <pre><code>$result = $search-&gt;search($keyword);
  echo "&lt;pre&gt;"; print_r($result); exit;
  </code></pre>
  
  <p>I'm running a foreach loop for <code>$results</code> to display. How can I add pagination of Elasticsearch?</p>
  
  <p>below is code for search:</p>
  
  <pre><code>$params = [
              'index' =&gt; $this-&gt;client-&gt;getIndex(),
              'type'  =&gt; $this-&gt;client-&gt;getType(),
              "from" =&gt; 0, "size" =&gt; 100,
              "scroll" =&gt; "1m",
  
              'body'  =&gt; [
             "query" =&gt; [
                 "bool" =&gt; [
                    "must" =&gt; [
                       [
                            "multi_match" =&gt; [
                                "fields" =&gt; ["prod_name", "prod_seo_name"],
                                "type" =&gt; "phrase_prefix",
                                "query" =&gt; $query
                            ]
                       ],
                       [
                            "term"=&gt; ["cat_type_id"=&gt;1]
                       ]
                    ]
                 ]
              ]
              ],
         ];
  </code></pre>
  
  <p>Querying in BD returns 400 records but elastic search giving 100 as I added size. How Do i scroll to another page?</p>
  
  <p>my URl: <a href="http://example.com/ppm2.0/search.html?q=samsung" rel="nofollow noreferrer">http://example.com/ppm2.0/search.html?q=samsung</a></p>