Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import requests, json, os
  2. from elasticsearch import Elasticsearch
  3. directory = '/home/minor-g2/Documents/rogier/genes/'
  4. res = requests.get('http://localhost:9200')
  5. print (res.content)
  6. es = Elasticsearch([{'host': 'localhost', 'port': '9200'}])
  7.  
  8. i = 1
  9. for filename in os.listdir(directory):
  10. if filename.endswith(".json"):
  11. f = open(filename)
  12. docket_content = f.read()
  13. # Send the data into es
  14. es.index(index='homosapiens', ignore=400, doc_type='gene',
  15. id=i, body=json.loads(docket_content))
  16. i = i + 1
  17.  
  18. # with open("./ElasticSearch/homo_sapiens.json") as file:
  19. # data = json.load(file)
  20. # index = 0
  21. # for gene in data["genes"]:
  22. # es.index(index='homosapiens', ignore=400, doc_type='gene', id=index, body=gene)
  23. # index += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement