[api] regenerate
This commit is contained in:
@ -1572,21 +1572,19 @@ var allTitles = [];
|
|||||||
// first we do a search, and specify a scroll timeout
|
// first we do a search, and specify a scroll timeout
|
||||||
client.search({
|
client.search({
|
||||||
index: 'myindex',
|
index: 'myindex',
|
||||||
// Set to 30 seconds because we are calling right back
|
scroll: '30s', // keep the search results "scrollable" for 30 seconds
|
||||||
scroll: '30s',
|
source: ['title'], // filter the source to only include the title field
|
||||||
search_type: 'scan',
|
|
||||||
fields: ['title'],
|
|
||||||
q: 'title:test'
|
q: 'title:test'
|
||||||
}, function getMoreUntilDone(error, response) {
|
}, function getMoreUntilDone(error, response) {
|
||||||
// collect the title from each response
|
// collect the title from each response
|
||||||
response.hits.hits.forEach(function (hit) {
|
response.hits.hits.forEach(function (hit) {
|
||||||
allTitles.push(hit.fields.title);
|
allTitles.push(hit._source.title);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.hits.total !== allTitles.length) {
|
if (response.hits.total > allTitles.length) {
|
||||||
// now we can call scroll over and over
|
// ask elasticsearch for the next set of hits from this search
|
||||||
client.scroll({
|
client.scroll({
|
||||||
scrollId: response._scroll_id,
|
scrollId: response.scroll_id,
|
||||||
scroll: '30s'
|
scroll: '30s'
|
||||||
}, getMoreUntilDone);
|
}, getMoreUntilDone);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user