#NEWLINE# def put( self , documents ) : #NEWLINE# #INDENT# 'Add `documents` to this index' #NEWLINE# def get_fields( d ) : #NEWLINE# #INDENT# 'Convenience function for getting the search API fields list\n            from the given document `d`.\n            ' #NEWLINE# field = ( lambda f , n , v : self . FIELD_MAP [ type ( f ) ] ( name = n , value = v ) ) #NEWLINE# return [ field ( f , n , f . to_search_value ( getattr ( d , n , None ) ) ) for ( n , f ) in d . _meta . fields . items ( ) ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# len ( documents ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# documents = [ documents ] #NEWLINE# #UNINDENT# search_docs = [ search_api . Document ( doc_id = d . doc_id , rank = d . _rank , fields = get_fields ( d ) ) for d in documents ] #NEWLINE# return self . _index . put ( search_docs )