#NEWLINE# @ scenario ( prepare_data , cleanup_data ) #NEWLINE# def test_search_with_scoring_and_lang( context ) : #NEWLINE# #INDENT# '\n    Search with custom scoring and language\n    ' #NEWLINE# t = QuerySet ( 'localhost' , index = 'foo' ) #NEWLINE# add_document ( 'foo' , { #NEWLINE# #INDENT# 'bar' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# add_document ( 'foo' , { #NEWLINE# #INDENT# 'bar' : 2 , #NEWLINE# #UNINDENT# } ) #NEWLINE# add_document ( 'foo' , { #NEWLINE# #INDENT# 'bar' : 3 , #NEWLINE# #UNINDENT# } ) #NEWLINE# score = ScriptScore ( "s = 0 + doc['bar'].value" , lang = 'mvel' ) #NEWLINE# t . score ( results ) #NEWLINE# results = t [ 0 : 10 ] #NEWLINE# len ( results ) . should . equal ( 3 ) #NEWLINE# results [ 0 ] [ '_source' ] [ 'bar' ] . should . equal ( 3 ) #NEWLINE# results [ 1 ] [ '_source' ] [ 'bar' ] . should . equal ( 2 ) #NEWLINE# results [ 2 ] [ '_source' ] [ 'bar' ] . should . equal ( 1 )