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!

1 Answer 1

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'})
Sign up to request clarification or add additional context in comments.

1 Comment

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.