#NEWLINE# def testUpdateUsingFunc( self ) : #NEWLINE# #INDENT# def update_list_values( current , extra ) : #NEWLINE# #INDENT# for ( k , v ) in extra . items ( ) : #NEWLINE# #INDENT# if isinstance ( current . get ( k ) , list ) : #NEWLINE# #INDENT# current [ k ] . extend ( v ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# current [ k ] = v #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . conn . index ( { #NEWLINE# #INDENT# 'name' : 'Joe Tester' , #NEWLINE# 'age' : 23 , #NEWLINE# 'skills' : [ 'QA' ] , #NEWLINE# #UNINDENT# } , self . index_name , self . document_type , 1 ) #NEWLINE# self . conn . indices . refresh ( self . index_name ) #NEWLINE# self . conn . update_by_function ( { #NEWLINE# #INDENT# 'age' : 24 , #NEWLINE# 'skills' : [ 'cooking' ] , #NEWLINE# #UNINDENT# } , self . index_name , self . document_type , 1 , update_func = update_list_values ) #NEWLINE# self . conn . indices . refresh ( self . index_name ) #NEWLINE# result = self . conn . get ( self . index_name , self . document_type , 1 ) #NEWLINE# self . assertResultContains ( result , { #NEWLINE# #INDENT# 'name' : 'Joe Tester' , #NEWLINE# 'age' : 24 , #NEWLINE# 'skills' : [ 'QA' , 'cooking' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertResultContains ( result . _meta , { #NEWLINE# #INDENT# 'index' : 'test-index' , #NEWLINE# 'type' : 'test-type' , #NEWLINE# 'id' : '1' , #NEWLINE# #UNINDENT# } )