# Elasticsearch: How to set custom record count based on a type in search result

**URL:** <https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973>\
**Category:** Elasticsearch\
**Created:** [April 12, 2014, 3:16am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973 "2014-04-12T03:16:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yyh3011](https://avatars.discourse-cdn.com/v4/letter/y/6de8d8/32.png) [@yyh3011](https://discuss.elastic.co/u/yyh3011)\
**Post date:** [April 12, 2014, 3:16am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973/1 "2014-04-12T03:16:54Z")

</div>

I have a search request like this:

My docs have a type, and the types like "sport", "health", "news" and etc,  
and now I want the result count is mapping percent by types: sport 10%,  
health 30%, news 60%.

Eg: if I search to get 200 records, I expect that the 200 records include  
20 news records, 60 health records and 120 news records.

I know I can calculate this after multiple search, but can I do it using  
one query?

thanks for any suggest!

johnson

--  
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/229aa050-51b9-46b6-8c89-0d457ca6c71f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/229aa050-51b9-46b6-8c89-0d457ca6c71f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![yyh3011](https://avatars.discourse-cdn.com/v4/letter/y/6de8d8/32.png) [@yyh3011](https://discuss.elastic.co/u/yyh3011)\
**Post date:** [April 15, 2014, 6:07am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973/2 "2014-04-15T06:07:59Z")

</div>

Anyone can give any suggests? thanks!

--  
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/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [April 15, 2014, 10:37am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973/3 "2014-04-15T10:37:12Z")

</div>

Hi,

It is not possible to do it in a single query. I think the easiest way to  
do that would be to issue several queries and merge results on client side.

On Tue, Apr 15, 2014 at 8:07 AM, [yyh3011@gmail.com](mailto:yyh3011@gmail.com) wrote:

> Anyone can give any suggests? thanks!
> 
> --  
> 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/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/693c5811-1124-4022-b572-cdac5399ae74%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j62jPdi3pN%2BfOOs0he1duGdaMXYmW\_mtVu60F5z7-uZmQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j62jPdi3pN%2BfOOs0he1duGdaMXYmW_mtVu60F5z7-uZmQ%40mail.gmail.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:35am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-set-custom-record-count-based-on-a-type-in-search-result/16973/4 "2017-07-06T01:35:48Z")

</div>


