[PATCH v2 compass-ci] es_query.rb: fix _scroll_id change

[why] _scroll_id will change every time query, so you need to save the last _scroll_id. Signed-off-by: Cui Yili <2268260388@qq.com> --- lib/es_query.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/es_query.rb b/lib/es_query.rb index dd6d97dc..8c5a28fe 100644 --- a/lib/es_query.rb +++ b/lib/es_query.rb @@ -45,11 +45,12 @@ class ESQuery }, size: size } result = @client.search index: @index, scroll: '10m', body: query - @scroll_id = result['_scroll_id'] - return result else - @client.scroll scroll: '10m', scroll_id: @scroll_id + result = @client.scroll scroll: '10m', scroll_id: @scroll_id end + + @scroll_id = result['_scroll_id'] unless result.empty? && result.include?('_scroll_id') + return result end def query_by_id(id) -- 2.23.0
participants (1)
-
Cui Yili