[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 22d68a9..6bd39bf 100644 --- a/lib/es_query.rb +++ b/lib/es_query.rb @@ -47,11 +47,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? + return result end
def query_by_id(id)