I can't figure out why is there such a difference between ES time and the query time.
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);
});
Output:
total time : [37]
ES >>>>> :2
As you can see, es result took shows query was executed in 2 ms, but if I calculate total time taken to run in code , it took 37ms. What took 35ms ?
“Took” parameter of Elasticsearch response is the correct indicator of the total time taken by a query (including time spent on sending requests to all relevant shards and gathering and combining the results from all shards).
You can use scroll API to retrieve more than 10000 records in elastic search as by default, 10000 is the upper cap for the number of documents returned.
A search consists of one or more queries that are combined and sent to Elasticsearch. Documents that match a search's queries are returned in the hits, or search results, of the response. A search may also contain additional information used to better process its queries.
Term queryedit. Returns documents that contain an exact term in a provided field. You can use the term query to find documents based on a precise value such as a price, a product ID, or a username.
According to this thread, the 'took' value measures wall time of query execution in Elasticsearch, which includes queue waiting time but excludes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With