我无法弄清楚为什么ES时间和查询时间之间存在这样的差异。
var url = "192.168.100.11:9200";
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: url
});
var accounts = [];
var startTime = new Date();
client.search({"index":"test", "type":"testdata1", searchType:"count"}).then(
function (searchData) {
var endDate = new Date();
console.log(" total time : [" + (endDate - startTime) + "]")
console.log(" ES >>>>> :" + JSON.stringify(searchData.took));
}).catch(function (err) {
console.log(" errr >>>> :" + err);
});
输出:
总时间:[37]
ES>>>>> :2
正如您所看到的,结果显示查询在2毫秒内执行,但如果我计算在代码中运行的总时间,则需要37毫秒。花了35毫秒?
答案 0 :(得分:8)
根据this thread,'''值测量Elasticsearch中查询执行的挂起时间,包括队列等待时间但不包括