diff --git a/docs/_examples/index.js b/docs/_examples/index.js deleted file mode 100644 index e35fa92e9..000000000 --- a/docs/_examples/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = [ - { - version: '*', - examples: {} - } -] diff --git a/docs/_examples/scroll_5.0+.asciidoc b/docs/_examples/scroll_5.0+.asciidoc new file mode 100644 index 000000000..5af890bfd --- /dev/null +++ b/docs/_examples/scroll_5.0+.asciidoc @@ -0,0 +1,28 @@ +.Collect every title in the index that contains the word "test" +[source,js] +--------- +var allTitles = []; + +// first we do a search, and specify a scroll timeout +client.search({ + index: 'myindex', + 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._source.title); + }); + + if (response.hits.total > allTitles.length) { + // ask elasticsearch for the next set of hits from this search + client.scroll({ + scrollId: response.scroll_id, + scroll: '30s' + }, getMoreUntilDone); + } else { + console.log('every "test" title', allTitles); + } +}); +--------- diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index b35fb1b55..8f0412c09 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -26,12 +26,9 @@ module.exports = function (branch, done) { aliases: {}, mergeConcatParams: {}, paramAsBody: {}, - clientActionModifier: false - }); - - var examples = version.mergeOpts(require('../../docs/_examples/index.js'), { + clientActionModifier: false, examples: {} - }).examples; + }); var steps = [ readSpecFiles, @@ -113,7 +110,7 @@ module.exports = function (branch, done) { [].concat(apiSpec.actions, apiSpec.proxies) .forEach(function (action) { - var examplePath = examples[action.name] || action.name + '.asciidoc'; + var examplePath = overrides.examples[action.name] || action.name + '.asciidoc'; try { action.examples = fs.readFileSync(fromRoot('docs/_examples', examplePath), 'utf8'); diff --git a/scripts/generate/overrides.js b/scripts/generate/overrides.js index 666f0f332..392f976df 100644 --- a/scripts/generate/overrides.js +++ b/scripts/generate/overrides.js @@ -248,6 +248,9 @@ function (spec) { '/_update_by_query/{task_id}/_rethrottle', '/_delete_by_query/{task_id}/_rethrottle' ] + }, + examples: { + scroll: 'scroll_5.0+.asciidoc' } } ];