code: def get_elastic_items_search(elastic, search_after=None, size=None):
      
  
      if not size:
          size = DEFAULT_LIMIT
  
      url = elastic.index_url + "/_search"
  
      search_after_query = ''
  
      if search_after:
          logging.debug("Search after: %s", search_after)
          # timestamp uuid
          search_after_query = ', "search_after": [%i, "%s"] ' % (search_after[0], search_after[1])
  
      query = """
      {
          "size": %i,
          "query": {
              "bool": {
                  "must": []
              }
          },
          "sort": [
              {"metadata__timestamp": "asc"},
              {"uuid": "asc"}
          ] %s
  
      }
      """ % (size, search_after_query)
  
      # logging.debug("%s\n%s", url, json.dumps(json.loads(query), indent=4))
      res = requests.post(url, data=query)
  
      rjson = None
      try:
          rjson = res.json()
      except Exception:
          logging.error("No JSON found in %s", res.text)
          logging.error("No results found from %s", url)
  
      return rjson
docs: Get the items from the index using search after scrolling