嗨,我无法弄清楚为什么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);
});
Run Code Online (Sandbox Code Playgroud)
输出:
总时间:[37]
ES >>>>>:2
正如你所看到的,结果显示查询在2毫秒内执行,但如果我计算在代码中运行所花费的总时间,则需要37毫秒.花了35ms?
| 归档时间: |
|
| 查看次数: |
2825 次 |
| 最近记录: |