#NEWLINE# def get_results( query ) : #NEWLINE# #INDENT# sources = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for row in scan_iter ( query ) : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# 'file_url' : url_for ( 'documents_api.file' , document_id = row . get ( '_id' ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# for ( name , value ) in row . get ( '_source' ) . items ( ) : #NEWLINE# #INDENT# if ( name == 'source_id' ) : #NEWLINE# #INDENT# if ( value not in sources ) : #NEWLINE# #INDENT# source = Source . by_id ( value ) #NEWLINE# if ( source is None ) : #NEWLINE# #INDENT# sources [ value ] = ( '[Deleted source %s]' % value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sources [ value ] = source . label #NEWLINE# #UNINDENT# #UNINDENT# value = sources [ value ] #NEWLINE# name = 'source' #NEWLINE# #UNINDENT# if ( name not in FIELDS ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if isinstance ( value , ( list , tuple , set ) ) : #NEWLINE# #INDENT# value = ', ' . join ( value ) #NEWLINE# #UNINDENT# data [ name ] = value #NEWLINE# #UNINDENT# ( yield data )