# Counting filtered queries

**URL:** <https://discuss.elastic.co/t/counting-filtered-queries/16829>\
**Category:** Elasticsearch\
**Created:** [April 4, 2014, 11:06pm UTC](https://discuss.elastic.co/t/counting-filtered-queries/16829 "2014-04-04T23:06:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spicylobe](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@spicylobe](https://discuss.elastic.co/u/spicylobe)\
**Post date:** [April 4, 2014, 11:06pm UTC](https://discuss.elastic.co/t/counting-filtered-queries/16829/1 "2014-04-04T23:06:07Z")

</div>

Based on the following, filtered queries clearly should be supported for  
the \_count endpoint.  
[http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-count](http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-count)

Whenever I use "filtered" instead of a "query", I always get an error like:

QueryParsingException[[a] request does not support [filtered]];  
Get the gist:

> <https://gist.github.com/logosdev/d236420f7d9e3806755d>

Is the documentation wrong, or I am constructing this query incorrectly?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4326a216-1ffe-4c0b-bb7a-6ddd7a74a4fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4326a216-1ffe-4c0b-bb7a-6ddd7a74a4fc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [April 9, 2014, 1:28pm UTC](https://discuss.elastic.co/t/counting-filtered-queries/16829/2 "2014-04-09T13:28:26Z")

</div>

Try putting filtered inside query, for example:

{  
"query": {  
"filtered": {  
"filter": {  
"match\_all": {}  
}  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8c469a43-615f-4f13-a9af-e5fd68fd18e4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8c469a43-615f-4f13-a9af-e5fd68fd18e4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spicylobe](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@spicylobe](https://discuss.elastic.co/u/spicylobe)\
**Post date:** [May 8, 2014, 7:32pm UTC](https://discuss.elastic.co/t/counting-filtered-queries/16829/3 "2014-05-08T19:32:47Z")

</div>

This worked! I think the docs should be updated though, they are still  
wrong at:  
[http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-count](http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-count)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/404955b1-c408-474e-b373-edad34ce99aa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/404955b1-c408-474e-b373-edad34ce99aa%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:30am UTC](https://discuss.elastic.co/t/counting-filtered-queries/16829/4 "2017-07-06T01:30:42Z")

</div>


