@@ -93,20 +93,29 @@ def get_es_output( options={} )
93
93
insist { r [ "_source" ] [ "counter" ] } == 3
94
94
end
95
95
96
- if ESHelper . es_version_satisfies? ( '<6' )
97
- context 'with an indexed script' do
98
- it "should increment a counter with event/doc 'count' variable with indexed script" do
99
- @es . put_script lang : 'painless' , id : 'indexed_update' , body : { script : 'ctx._source.counter += params.event.count' }
100
- subject = get_es_output ( {
101
- 'document_id' => "123" ,
102
- 'script' => 'indexed_update' ,
103
- 'script_type' => 'indexed'
104
- } )
105
- subject . register
106
- subject . multi_receive ( [ LogStash ::Event . new ( "count" => 4 ) ] )
107
- r = @es . get ( :index => 'logstash-update' , :type => 'logs' , :id => "123" , :refresh => true )
108
- insist { r [ "_source" ] [ "counter" ] } == 5
96
+ context 'with an indexed script' do
97
+ it "should increment a counter with event/doc 'count' variable with indexed script" do
98
+ if ESHelper . es_version_satisfies? ( '<6' )
99
+ @es . perform_request ( :put , "_scripts/painless/indexed_update" , { } , { "script" => "ctx._source.counter += params.event.count" } )
100
+ else
101
+ @es . perform_request ( :put , "_scripts/indexed_update" , { } , { "script" => { "source" => "ctx._source.counter += params.event.count" , "lang" => "painless" } } )
102
+ end
103
+
104
+ plugin_parameters = {
105
+ 'document_id' => "123" ,
106
+ 'script' => 'indexed_update' ,
107
+ 'script_type' => 'indexed'
108
+ }
109
+
110
+ if ESHelper . es_version_satisfies? ( '>= 6.0.0' )
111
+ plugin_parameters . merge! ( 'script_lang' => '' )
109
112
end
113
+
114
+ subject = get_es_output ( plugin_parameters )
115
+ subject . register
116
+ subject . multi_receive ( [ LogStash ::Event . new ( "count" => 4 ) ] )
117
+ r = @es . get ( :index => 'logstash-update' , :type => 'logs' , :id => "123" , :refresh => true )
118
+ insist { r [ "_source" ] [ "counter" ] } == 5
110
119
end
111
120
end
112
121
end
0 commit comments