Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. from elasticsearch import Elasticsearch
  2. from elasticsearch.helpers import scan as escan
  3. import pandas as pd
  4.  
  5. es = Elasticsearch(dpl_server, verify_certs=False)
  6.  
  7. body = {
  8. "size": 1000,
  9. "query": {
  10. "match_all": {}
  11. }
  12. }
  13. response = escan(client=es,
  14. index="index-*,
  15. query=body, request_timeout=30, size=1000)
  16. print(response)
  17. #<generator object scan at 0x000001BF5A25E518>
  18.  
  19. for res in response:
  20. print(res['_source'])
  21. # { .... }
  22. # { .... }
  23. # { .... }
  24.  
  25. df = None
  26. for res in response:
  27. if (df is None):
  28. df = pd.DataFrame([res['_source']])
  29. else:
  30. df = pd.concat([df, pd.DataFrame([res['_source']])], sort=True)
Add Comment
Please, Sign In to add comment