Skip to content

Commit

Permalink
Merge pull request #1039 from uken/avoid-to-use-deprecated-parametriz…
Browse files Browse the repository at this point in the history
…ed-api

in_elasticsearch: Avoid to use deprecated endpoint for clear_scroll
  • Loading branch information
cosmo0920 authored Dec 5, 2023
2 parents 5a78a93 + b137164 commit c54b277
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/fluent/plugin/in_elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ def run_slice(slice_id=nil)
end

router.emit_stream(@tag, es)
client.clear_scroll(scroll_id: scroll_id) if scroll_id
if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("7.0.0")
client.clear_scroll(body: {scroll_id: scroll_id}) if scroll_id
else
client.clear_scroll(scroll_id: scroll_id) if scroll_id
end
end

def process_scroll_request(scroll_id)
Expand Down
9 changes: 7 additions & 2 deletions test/plugin/test_in_elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,14 @@ def test_emit_with_size
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}}
end
end)
stub_request(:delete, "http://localhost:9200/_search/scroll/WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz").
if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("7.0.0")
stub_request(:delete, "http://localhost:9200/_search/scroll").
with(body: "{\"scroll_id\":\"WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz\"}").
to_return(status: 200, body: "", headers: {})

else
stub_request(:delete, "http://localhost:9200/_search/scroll/WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz").
to_return(status: 200, body: "", headers: {})
end
driver(CONFIG + %[size 1])
driver.run(expect_emits: 1, timeout: 10)
expected = [
Expand Down

0 comments on commit c54b277

Please sign in to comment.