0

I am using elasticsearch js within my application and have successfully connected and queried data from elastic.

I am now trying to implement the count() method to return the number of documents in the index. Here is the simple code snippet:

elasticClient.count(/* params: CountParams */)

I replaced params: CountParams with indexName but I now receive an illegal argument exception saying that ... [/_count] contains unrecognized parameters ...

I cannot find any documentation anywhere, whether on the api, stack overflow, or on other sites, regarding the count method.

I would greatly appreciate it if anyone could provide a working example or any links.

Thank you!

lve
  • 307
  • 2
  • 5
  • 15

1 Answers1

0

Does this help? Seems like that would be what you need, though it does not contain an actual example.

edit: how exactly does your call look? I'm not using the js client currently, but I assume you would have to add the parameter? Something like this maybe?

elasticClient.count({index: 'index-name'})
Stefano Branco
  • 658
  • 3
  • 14
  • That works! I have to manipulate it a little bit more to actually return the count, since it returns a Promise, but that's easy enough. Thank you! – lve Jul 09 '19 at 14:29