From 212a2aa9b06a4fcdbceb51099862f288e6e6626b Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 16 Nov 2016 11:54:34 -0700 Subject: [PATCH] [api] regenerate --- docs/api_methods.asciidoc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/api_methods.asciidoc b/docs/api_methods.asciidoc index 6a8918dcb..544bb2b11 100644 --- a/docs/api_methods.asciidoc +++ b/docs/api_methods.asciidoc @@ -1572,21 +1572,19 @@ var allTitles = []; // first we do a search, and specify a scroll timeout client.search({ index: 'myindex', - // Set to 30 seconds because we are calling right back - scroll: '30s', - search_type: 'scan', - fields: ['title'], + scroll: '30s', // keep the search results "scrollable" for 30 seconds + source: ['title'], // filter the source to only include the title field q: 'title:test' }, function getMoreUntilDone(error, response) { // collect the title from each response response.hits.hits.forEach(function (hit) { - allTitles.push(hit.fields.title); + allTitles.push(hit._source.title); }); - if (response.hits.total !== allTitles.length) { - // now we can call scroll over and over + if (response.hits.total > allTitles.length) { + // ask elasticsearch for the next set of hits from this search client.scroll({ - scrollId: response._scroll_id, + scrollId: response.scroll_id, scroll: '30s' }, getMoreUntilDone); } else {