下記のコードをご覧ください。私が達成したいのは、バッチサイズ(50)あたりの数を制限することですが、TOTAL結果(1000)の数も制限します。コードサンプルを使用して、私は結果としてすべての一致するレコードを取得します。私は間違って何をしていますか?または、これはまったくサポートされていません。弾性検索スクロール制限件数
ありがとうございます!
サンダー
var elasticsearch = require('elasticsearch');
var _ = require('lodash');
var client = new elasticsearch.Client({
host: 'host',
log: 'info'
});
var allDocuments = [];
client.search({
index: "index",
type: "type",
scroll: '30s',
size: 50,
body: {
"from": 0,
"size": 1000,
"query": {
"range": {
"updated": {
"gte": "2016-10-24T08:35:10.540Z",
"lte": "2016-10-29T20:35:10.541Z"
}
}
}
}
}, function getMoreUntilDone(error, response) {
response.hits.hits.forEach(function (hit) {
allDocuments.push(hit._source);
});
if (response.hits.total !== allDocuments.length) {
client.scroll({
scrollId: response._scroll_id,
scroll: '30s'
}, getMoreUntilDone);
} else {
console.log('count', allDocuments.length);
}
});
はちょうど私の同様の質問に答えを取得した後、terminateAfterが体外に行くこれを見つけました:https://stackoverflow.com/questions/45713583/using-elasticsearch-terminate-after-in-query-body- in-javascript/45713729#45713729 – Carasel