# Hits + query\_cache=true + aggs in 1 round trip: \_msearch?

**URL:** <https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882>\
**Category:** Elasticsearch\
**Created:** [February 26, 2016, 5:51pm UTC](https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882 "2016-02-26T17:51:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke\_Nezda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luke_nezda/32/47152_2.png) [@Luke\_Nezda](https://discuss.elastic.co/u/Luke_Nezda)\
**Post date:** [February 26, 2016, 5:51pm UTC](https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882/1 "2016-02-26T17:51:38Z")

</div>

Hello, All -

I'd like to benefit from query cache of aggregations when possible AND get hits AND aggregations in a single round trip. It occurred to me, I can just run a pair of related queries against `_msearch` where one is for aggregations (still filtered by a query, but ignoring its hits (`search_type=count`)) and the other is just the query (no aggregations). Basically, just to work around the current limitation that `query_cache=true` requires `search_type=count` ([https://www.elastic.co/guide/en/elasticsearch/reference/1.7/index-modules-shard-query-cache.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/index-modules-shard-query-cache.html)).

e.g., send `_msearch`

```auto
{"index" : "some_index", "search_type": "count", "query_cache": true}
{ ...query with aggs for the aggs... }
{"index" : "some_index"}
{ ...same query without aggs for the hits... }

```

This seems to work but feels contorted. Is there an easier thing I should be doing instead? (e.g., `"index.cache.query.enable": true` or something?) (currently on es 1.7.4)

Please advise,

- Luke

---

<div class="post-metadata">

**Author:** ![Luke\_Nezda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luke_nezda/32/47152_2.png) [@Luke\_Nezda](https://discuss.elastic.co/u/Luke_Nezda)\
**Post date:** [February 27, 2016, 1:30pm UTC](https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882/2 "2016-02-27T13:30:01Z")

</div>

Some renames, but looks like this would still work in 2.x [https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html) with size=0 and request\_cache=true

---

<div class="post-metadata">

**Author:** ![Luke\_Nezda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luke_nezda/32/47152_2.png) [@Luke\_Nezda](https://discuss.elastic.co/u/Luke_Nezda)\
**Post date:** [March 15, 2016, 1:49am UTC](https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882/3 "2016-03-15T01:49:23Z")

</div>

Elasticsearch devs this seems to net a significant improvement for us: is that a surprise ? Are there downsides?

---

<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 5, 2017, 11:08pm UTC](https://discuss.elastic.co/t/hits-query-cache-true-aggs-in-1-round-trip--msearch/42882/4 "2017-07-05T23:08:33Z")

</div>


