I could not find any documentation within the api, stack overflow, and other sites relating to the count method, called by:
elasticClient.count(/* params: CountParams */)
From my understanding, count provides the number of documents within a specified index in elastic. Passing the index name as the sole parameter results in an error and I cannot find any docs specifying params required or other information.
I would appreciate it if anyone could provide a link to any documentation regarding use cases/examples, or take the time to add to the api if it does not exist. Thank you!
happens to me too :(
This elastic documentation is the closest the I could find for docs, thanks to this answer on stack overflow.
In case anyone else needs a quick example, I'll take the liberty of adding one below, assuming your elastic client is already up and running.
elasticClient.count({index: 'index-name'}).then(results => {
var count = results["count"];
// The reason I need to do '.then' is because it returns a Promise, not the actual count
// Do stuff with the count if you want
// Look at results if you also want shard information
});
Hello! It appears that you are using the legacy client. The documentation you pointed out is for the new client, the API surface is the same, but the returned value is different.
Let me know if you have more question!
Most helpful comment
happens to me too :(