Hello,
Good day to you all.

I am quite new to redash and in this forum, but this is the first time I ever made a question here.

Let’s say I want to count the total docs in my index, how can I approach this?
Do I just have to make a simple query or do I need to define an aggregation first, counting the total documents?
Tested using PostgreSQL is quite simple, I succeded to get the value that I want.
But I have no idea as how to approach this on ElasticSearch, even on a simple thing like getting the total docs.
Hopefully someone here that has prior experience with this can point me to the right direction.

pak

Up.
Just checking if someone can help me with this.

Thanks,
pak

Unless you have very small amount of documents in your index, the best approach is to make an Elasticsearch query that returns the count of documents. Then you can use the Counter visualization to show this value.

Hi Arik,
Thank you for answering this.

Is there any sample that can show me how to do it in more details?
Because I have tried to achieve this by making an aggregation in my query. Unfortunately, I cannot see the result show up in the default table visualization.

Thanks,
pak

Hi Arik,
So I have tried to use a simple query to do this, no result, the counter didn’t detect the total hits like what I hoped to.
Same thing happened when I used aggs.

Though I found that counter actually have “count rows”. Looks like it’s counting the “rows” from the query result.
But, since the query has “10000” limit on the size, it is not suitable for my needs. Because I have quite large amount of data.

Instead of using the count rows, is there any way to use the total hits from query result?

Thanks,
-pak-

You need to use an aggregate query to return the real count of the rows. The current Elasticsearch connector has issues with some variants of aggregate queries, but there is a new one being developed that should address these issues and support SQL.

There is no ETA on when this will be done, but the plan is to have this as part of the next release.

Hi @arikfr,
thank you for the answer.

I was guessing that this is the reason why I cannot achieve what I want to do.
Turns out I was right.
Hopefully it will be done soon.

Thanks,
pak