Created
          April 8, 2016 13:22 
        
      - 
      
 - 
        
Save varundey/8d5435979e7e344defe6821eba5d500e to your computer and use it in GitHub Desktop.  
    indexing for elasticsearch
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env python | |
| from elasticsearch import Elasticsearch | |
| es = Elasticsearch() | |
| import json | |
| import os | |
| x= os.listdir("/home/varun/Desktop/git/zeroclickinfo-goodies/share/goodie/cheat_sheets/json") | |
| li=[] | |
| for xx in x: | |
| try: | |
| if ".json" in xx: | |
| js = json.loads(open("/home/varun/Desktop/git/zeroclickinfo-goodies/share/goodie/cheat_sheets/json/"+xx,"r").read()) | |
| print xx | |
| res = es.index(index="ddg", doc_type='cheatsheet', id=xx, body=js) | |
| print(res['created']) | |
| except Exception as e: | |
| li.append(xx+str(e)) | |
| print li | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment