Skip to content

Instantly share code, notes, and snippets.

@kylegallatin
Last active April 19, 2019 00:00
Show Gist options
  • Save kylegallatin/c36fb641807e35e9b6bb8ad539415748 to your computer and use it in GitHub Desktop.
Save kylegallatin/c36fb641807e35e9b6bb8ad539415748 to your computer and use it in GitHub Desktop.
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
es = Elasticsearch(['localhost:9200'])
docs = pdf2txt(pdf_path)
index = "mueller-report"
##good practice to delete an index if it already exists and you're overwriting
if es.indices.exists(index):
es.indices.delete(index)
## elastic helper function to bulk index json
bulk(es, docs, index=index, doc_type='clue', raise_on_error=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment