Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, json, os
- from elasticsearch import Elasticsearch
- directory = '/home/minor-g2/Documents/rogier/genes/'
- res = requests.get('http://localhost:9200')
- print (res.content)
- es = Elasticsearch([{'host': 'localhost', 'port': '9200'}])
- i = 1
- for filename in os.listdir(directory):
- if filename.endswith(".json"):
- f = open(filename)
- docket_content = f.read()
- # Send the data into es
- es.index(index='homosapiens', ignore=400, doc_type='gene',
- id=i, body=json.loads(docket_content))
- i = i + 1
- # with open("./ElasticSearch/homo_sapiens.json") as file:
- # data = json.load(file)
- # index = 0
- # for gene in data["genes"]:
- # es.index(index='homosapiens', ignore=400, doc_type='gene', id=index, body=gene)
- # index += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement