How much resource consuming is to get count only from ES ? What are the ways to just count the total documents?

I have around 2 million documents in my Index currently. Now I have some
pages where i have to show the statistics of the content. I just want the
total counts of the documents. But I have to use the complex filters, so
that i can count only the required documents. Mostly I'm using the "bool"
and "and" in my queries.

I think I can just send limit : 0 , to fetch the documents, and get the
total count from the "total hits", but I am not sure will it be fast or is
there any other way to just count the total documents.

Hi Chetan,

Not sure if you saw Elasticsearch Platform — Find real-time answers at scale | Elastic

Otis

Sematext - Hiring Elasticsearch / Solr Devs - Jobs - Sematext

On Jan 18, 12:50 am, Chetan Sharma c...@izap.in wrote:

I have around 2 million documents in my Index currently. Now I have some
pages where i have to show the statistics of the content. I just want the
total counts of the documents. But I have to use the complex filters, so
that i can count only the required documents. Mostly I'm using the "bool"
and "and" in my queries.

I think I can just send limit : 0 , to fetch the documents, and get the
total count from the "total hits", but I am not sure will it be fast or is
there any other way to just count the total documents.

Another option is to set search_type in the search request to count. The
benefit there is that you can also get facets for example.

On Wed, Jan 18, 2012 at 7:56 AM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

Hi Chetan,

Not sure if you saw
Elasticsearch Platform — Find real-time answers at scale | Elastic

Otis

Sematext - Hiring Elasticsearch / Solr Devs -
Jobs - Sematext

On Jan 18, 12:50 am, Chetan Sharma c...@izap.in wrote:

I have around 2 million documents in my Index currently. Now I have some
pages where i have to show the statistics of the content. I just want the
total counts of the documents. But I have to use the complex filters, so
that i can count only the required documents. Mostly I'm using the "bool"
and "and" in my queries.

I think I can just send limit : 0 , to fetch the documents, and get the
total count from the "total hits", but I am not sure will it be fast or
is
there any other way to just count the total documents.

Thanks Guys.. Its great help.

Just one more question. Will it take the same time as query and fetch the
document, or it is faster ?

You mean search_type set to count? If so, it will be faster, since you
don't need to bring back any hits back, even if you set size to 0,
search_type set to count will be faster.

On Fri, Jan 20, 2012 at 2:53 PM, Chetan Sharma carl@izap.in wrote:

Just one more question. Will it take the same time as query and fetch the
document, or it is faster ?

Thanks.

On Fri, Jan 20, 2012 at 8:31 PM, Shay Banon kimchy@gmail.com wrote:

You mean search_type set to count? If so, it will be faster, since you
don't need to bring back any hits back, even if you set size to 0,
search_type set to count will be faster.

On Fri, Jan 20, 2012 at 2:53 PM, Chetan Sharma carl@izap.in wrote:

Just one more question. Will it take the same time as query and fetch the
document, or it is faster ?

--

Your Sincerely,
Chetan Sharma iZAPTeam ( Social Network Promoter )
http://www.izap.in
Exclusive ElggStore: http://www.pluginlotto.com

Thanks alot. This was what I wanted :slight_smile: