<s> import sys <EOL> from pyes . es import ES <EOL> from datetime import datetime <EOL> import shelve <EOL> conn = ES ( '<STR_LIT>' ) <EOL> try : <EOL> conn . delete_index ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> dataset = shelve . open ( "<STR_LIT>" ) <EOL> mapping = { u'<STR_LIT:description>' : { '<STR_LIT>' : <NUM_LIT:1.0> , <EOL> '<STR_LIT:index>' : '<STR_LIT>' , <EOL> '<STR_LIT:store>' : '<STR_LIT:yes>' , <EOL> '<STR_LIT:type>' : u'<STR_LIT:string>' , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> u'<STR_LIT:name>' : { '<STR_LIT>' : <NUM_LIT:1.0> , <EOL> '<STR_LIT:index>' : '<STR_LIT>' , <EOL> '<STR_LIT:store>' : '<STR_LIT:yes>' , <EOL> '<STR_LIT:type>' : u'<STR_LIT:string>' , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> u'<STR_LIT>' : { '<STR_LIT:store>' : '<STR_LIT:yes>' , <EOL> '<STR_LIT:type>' : u'<STR_LIT>' } , <EOL> } <EOL> conn . create_index ( "<STR_LIT>" ) <EOL> conn . put_mapping ( "<STR_LIT>" , { '<STR_LIT>' : mapping } , [ "<STR_LIT>" ] ) <EOL> start = datetime . now ( ) <EOL> for k , userdata in dataset . items ( ) : <EOL> conn . index ( userdata , "<STR_LIT>" , "<STR_LIT>" , k , bulk = True ) <EOL> conn . force_bulk ( ) <EOL> end = datetime . now ( ) <EOL> print "<STR_LIT>" , end - start <EOL> dataset . close ( ) </s>
