<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import logging <EOL> import elasticsearch <EOL> from h . api import presenters <EOL> log = logging . getLogger ( __name__ ) <EOL> def index ( es , annotation , request ) : <EOL> """<STR_LIT>""" <EOL> annotation_dict = presenters . AnnotationJSONPresenter ( <EOL> request , annotation ) . asdict ( ) <EOL> annotation_dict [ '<STR_LIT:target>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = [ <EOL> annotation . target_uri_normalized ] <EOL> es . conn . index ( <EOL> index = es . index , <EOL> doc_type = es . t . annotation , <EOL> body = annotation_dict , <EOL> id = annotation_dict [ "<STR_LIT:id>" ] , <EOL> ) <EOL> def delete ( es , annotation ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> es . conn . delete ( <EOL> index = es . index , <EOL> doc_type = es . t . annotation , <EOL> id = annotation . id , <EOL> ) <EOL> except elasticsearch . NotFoundError : <EOL> log . exception ( '<STR_LIT>' <EOL> '<STR_LIT>' , annotation . id ) </s>
