# Search Template with Count API

**URL:** <https://discuss.elastic.co/t/search-template-with-count-api/20496>\
**Category:** Elasticsearch\
**Created:** [October 30, 2014, 11:37am UTC](https://discuss.elastic.co/t/search-template-with-count-api/20496 "2014-10-30T11:37:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sofiane\_Cherchalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sofiane_cherchalli/32/1129_2.png) [@Sofiane\_Cherchalli](https://discuss.elastic.co/u/Sofiane_Cherchalli)\
**Post date:** [October 30, 2014, 11:37am UTC](https://discuss.elastic.co/t/search-template-with-count-api/20496/1 "2014-10-30T11:37:14Z")

</div>

I am using Search Templates for performing queries.

How can I get the count with search template?

Example:

PUT blogs/post/1  
{  
"title": "title1",  
"desc": "desc1"  
}

PUT /blogs/post/2  
{  
"title": "title2",  
"desc": "desc2"  
}

PUT /\_search/template/search\_posts  
{  
"template": {  
"query": {  
"match\_all": {}  
}  
}  
}

GET /blogs/post/\_search/template  
{  
"template": {  
"id": "search\_posts"  
},  
"params": {}  
}

GET blogs/post/\_search  
{  
"query": {  
"match\_all": {}  
}  
}

GET blogs/post/\_count  
{  
"query": {  
"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/b54d4ba5-3cee-4248-803b-df66dd4cacca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b54d4ba5-3cee-4248-803b-df66dd4cacca%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, 12:53am UTC](https://discuss.elastic.co/t/search-template-with-count-api/20496/2 "2017-07-06T00:53:01Z")

</div>

Closed on July 6, 2017, 12:53am UTC


