Hello,
In the documentation and the vignette, the scroll example is incorrect.
At least for my case with elasticsearch 2.3
The example is the following;
res <- Search(index = 'shakespeare', q="a*", time_scroll="5m")
out <- list()
hits <- 1
while(hits != 0){
res <- scroll(res$`_scroll_id`)
hits <- length(res$hits$hits)
if(hits > 0)
out <- c(out, res$hits$hits)
}
But by doing so, since the default size of Search is 10, you miss 10 results from the first Search.
Actually, the first Search return a scroll id for the next results.
And I think that if you add the time_scroll in the first Search, you should as well in the scroll.
So I think that the example should be something like this, in order to retrieve all the results:
res <- Search(index = 'shakespeare', q="a*", time_scroll="5m")
out <- list()
hits <- length(res$hits$hits)
if(hits > 0){
out <- c(out, res$hits$hits)
while(hits != 0){
res <- scroll(res$`_scroll_id`, time_scroll="5m")
hits <- length(res$hits$hits)
if(hits > 0){
out <- c(out, res$hits$hits)
}
}
}
Hello, In the documentation and the vignette, the scroll example is incorrect. At least for my case with elasticsearch 2.3
The example is the following;
But by doing so, since the default size of Search is 10, you miss 10 results from the first Search. Actually, the first Search return a scroll id for the next results. And I think that if you add the time_scroll in the first
Search
, you should as well in thescroll
.So I think that the example should be something like this, in order to retrieve all the results: