Hello everyone,
I need to get the total count of a field in Elasticsearch (in my case, the number of clients in client field). How do I write the query in Dev tools?
Hello everyone,
I need to get the total count of a field in Elasticsearch (in my case, the number of clients in client field). How do I write the query in Dev tools?
A terms aggregation should do it I guess...
Hello @dadoonet,
I tried the terms aggregation query but it is not providing the total count of client. It is dividing the client into different parts and then providing the total of each part.
What do you mean?
Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
Have a look at the Elastic Stack and Solutions Help · Forums and Slack | Elastic page. It contains also lot of useful information on how to ask for help.
Hello @dadoonet,
Please see the 2 attached screenshots.
In the first screenshot, we can see that the client field is being divided into small parts. And I need the total count of client to be displayed like in the second screenshot.
Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.
Instead, paste the text and format it with </>
icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.
But anyway, here I think you want to use: Cardinality aggregation | Elasticsearch Guide [8.9] | Elastic
Hello @dadoonet,
Well noted. And thank you for your help.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.