title: How to insert data from OpenSearch to Excel using python
body: <p>I have already written code but still having some trouble with below two scenarios.</p>
  <ol>
  <li>Inserting More than 10k records</li>
  <li>Setting up incremental load</li>
  </ol>
  <p>Reference: opensearch-py can be used as a python client</p>
  <p>Sample Code:</p>
  <pre><code>from opensearchpy import OpenSearch
  
  host = ''
  port = 
  auth = ('', '') 
  
  # Create the client with SSL/TLS enabled, but hostname verification disabled.
  client = OpenSearch(
      hosts = [{'host': host, 'port': port}],
      http_compress = True, # enables gzip compression for request bodies
      http_auth = auth,
      # client_cert = client_cert_path,
      # client_key = client_key_path,
      use_ssl = True,
      verify_certs = False,
      ssl_assert_hostname = False,
      ssl_show_warn = False
  )
  
  # # Create an index with non-default settings.
  index_name = ''
  
  # Search for the document.
  query = {
    &quot;query&quot;: {
      &quot;match_all&quot; : {}
    }
  }
  
  res = client.search(
      body = query,
      index = index_name,
      scroll = '2m',
      size = 10000,
  )
  # print('\nSearch results:')
  # print(response)
  
  from pandas.io.json import json_normalize
  df = json_normalize(res['hits']['hits'])
  df.to_excel (r'export_dataframe.xlsx', index = False, header=True)
  </code></pre>