# Aggregation query works with search, but not with msearch

**URL:** <https://discuss.elastic.co/t/aggregation-query-works-with-search-but-not-with-msearch/19478>\
**Category:** Elasticsearch\
**Created:** [August 26, 2014, 11:12pm UTC](https://discuss.elastic.co/t/aggregation-query-works-with-search-but-not-with-msearch/19478 "2014-08-26T23:12:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhruv\_Garg](https://avatars.discourse-cdn.com/v4/letter/d/d78d45/32.png) [@Dhruv\_Garg](https://discuss.elastic.co/u/Dhruv_Garg)\
**Post date:** [August 26, 2014, 11:12pm UTC](https://discuss.elastic.co/t/aggregation-query-works-with-search-but-not-with-msearch/19478/1 "2014-08-26T23:12:45Z")

</div>

I am trying to troubleshoot the following observation:

Following code works as expected:

Elasticsearch::Model.client.search search\_type: 'count', index:  
target\_indices, body: query

Response:

{"took"=\>2, "timed\_out"=\>false, "\_shards"=\>{"total"=\>2, "successful"=\>2,  
"failed"=\>0}, "hits"=\>{"total"=\>6, "max\_score"=\>0.0, "hits"=\>[]},  
"aggregations"=\>{"recent"=\>{"doc\_count"=\>3,  
"searches"=\>{"buckets"=\>[{"key"=\>"user-1", "doc\_count"=\>3}]}}}}

However, when using the above in an msearch, the response is not useful:

Elasticsearch::Model.client.msearch body: [{ search\_type: 'count', index:  
target\_indices, search: query }]

Response:

{"responses"=\>[{"took"=\>0, "timed\_out"=\>false, "\_shards"=\>{"total"=\>2,  
"successful"=\>2, "failed"=\>0}, "hits"=\>{"total"=\>6, "max\_score"=\>0.0,  
"hits"=\>[]}}]}

* * *

What am I missing?

--  
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/2fef8c41-7232-43e6-8632-9e2e5058240d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2fef8c41-7232-43e6-8632-9e2e5058240d%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:06am UTC](https://discuss.elastic.co/t/aggregation-query-works-with-search-but-not-with-msearch/19478/2 "2017-07-06T01:06:12Z")

</div>


