# Shard query cache not working for aggregates with simple date range filter

**URL:** <https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335>\
**Category:** Elasticsearch\
**Created:** [December 19, 2014, 6:49pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335 "2014-12-19T18:49:27Z")\
**Posts on this page:** 7\
**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:** [December 19, 2014, 6:49pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/1 "2014-12-19T18:49:27Z")

</div>

I'm using Elasticsearch 1.4.2 and was excited about the new shard query  
cache  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html),  
but I am surprised this simple terms aggregate doesn't seem to show up in  
the cache if I have a date range filter:  
[https://gist.github.com/nezda/c65dd66785d5f1e4dbd4](https://gist.github.com/nezda/c65dd66785d5f1e4dbd4) -- I'm not referencing  
`now` or anything, so this seems like a bug to me.

Please advise,

- Luke

--  
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/fc9298f9-cb10-4698-a8f5-09b4d7e19713%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fc9298f9-cb10-4698-a8f5-09b4d7e19713%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 17, 2015, 4:41pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/2 "2015-02-17T16:41:22Z")

</div>

Answering myself: this was reported as a bug several weeks  
later [Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) and the  
fix was just released  
via [Queries are never cached when date math expressions are used (including exact dates) by jpountz · Pull Request #9269 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/9269) in 1.4.3. Do  
es devs read this list? Is this the wrong venue for this kind of feedback?  
I had a gist and everything.

On Friday, December 19, 2014 at 12:49:27 PM UTC-6, Luke Nezda wrote:

> I'm using Elasticsearch 1.4.2 and was excited about the new shard query  
> cache  
> [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html),  
> but I am surprised this simple terms aggregate doesn't seem to show up in  
> the cache if I have a date range filter:  
> [Agg query\_cache not working with date filter · GitHub](https://gist.github.com/nezda/c65dd66785d5f1e4dbd4) -- I'm not referencing  
> `now` or anything, so this seems like a bug to me.
> 
> Please advise,
> 
> - Luke

--  
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/2c926e1d-b6de-4929-84ab-3c0f5f61b7f9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2c926e1d-b6de-4929-84ab-3c0f5f61b7f9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jared\_P](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Jared\_P](https://discuss.elastic.co/u/Jared_P)\
**Post date:** [February 17, 2015, 6:57pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/3 "2015-02-17T18:57:21Z")

</div>

Luke - I've been having this same problem as you originally posted. I just  
updated to Elasticsearch 1.4.3 and haven't seen any change of behavior when  
using a date range. In fact, it looks like the Gist you posted is still  
failing as it was for ES 1.4.2. Have you seen any changes since upgrading  
to 1.4.3?

On Tuesday, February 17, 2015 at 11:41:22 AM UTC-5, Luke Nezda wrote:

> Answering myself: this was reported as a bug several weeks later  
> [Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) and the fix  
> was just released via  
> [Queries are never cached when date math expressions are used (including exact dates) by jpountz · Pull Request #9269 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/9269) in 1.4.3. Do es  
> devs read this list? Is this the wrong venue for this kind of feedback? I  
> had a gist and everything.
> 
> On Friday, December 19, 2014 at 12:49:27 PM UTC-6, Luke Nezda wrote:
> 
> > I'm using Elasticsearch 1.4.2 and was excited about the new shard query  
> > cache  
> > [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html),  
> > but I am surprised this simple terms aggregate doesn't seem to show up in  
> > the cache if I have a date range filter:  
> > [Agg query\_cache not working with date filter · GitHub](https://gist.github.com/nezda/c65dd66785d5f1e4dbd4) -- I'm not  
> > referencing `now` or anything, so this seems like a bug to me.
> > 
> > Please advise,
> > 
> > - Luke

--  
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/e64008eb-1ff6-4653-9111-8669c1cf698f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e64008eb-1ff6-4653-9111-8669c1cf698f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 17, 2015, 7:36pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/4 "2015-02-17T19:36:34Z")

</div>

Jared -

Silly me for assuming... No, I haven't actually tested with 1.4.3, it just  
sounded the same. Did you try testing with @ppf2's  
gist [query cache test · GitHub](https://gist.github.com/ppf2/bfa38b8284e09c0740ad) from  
[Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) - it would be  
particularly weird & disappointing if that was still broken too, but I  
suppose mine could be different issue. I'm happy to hear _something_ on  
this thread!

On Tuesday, February 17, 2015 at 12:57:21 PM UTC-6, Jared P wrote:

> Luke - I've been having this same problem as you originally posted. I  
> just updated to Elasticsearch 1.4.3 and haven't seen any change of behavior  
> when using a date range. In fact, it looks like the Gist you posted is  
> still failing as it was for ES 1.4.2. Have you seen any changes since  
> upgrading to 1.4.3?
> 
> On Tuesday, February 17, 2015 at 11:41:22 AM UTC-5, Luke Nezda wrote:
> 
> > Answering myself: this was reported as a bug several weeks later  
> > [Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) and the fix  
> > was just released via  
> > [Queries are never cached when date math expressions are used (including exact dates) by jpountz · Pull Request #9269 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/9269) in 1.4.3. Do  
> > es devs read this list? Is this the wrong venue for this kind of feedback?  
> > I had a gist and everything.
> > 
> > On Friday, December 19, 2014 at 12:49:27 PM UTC-6, Luke Nezda wrote:
> > 
> > > I'm using Elasticsearch 1.4.2 and was excited about the new shard query  
> > > cache  
> > > [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html),  
> > > but I am surprised this simple terms aggregate doesn't seem to show up in  
> > > the cache if I have a date range filter:  
> > > [Agg query\_cache not working with date filter · GitHub](https://gist.github.com/nezda/c65dd66785d5f1e4dbd4) -- I'm not  
> > > referencing `now` or anything, so this seems like a bug to me.
> > > 
> > > Please advise,
> > > 
> > > - Luke

--  
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/aae6efaf-587f-4596-a6ff-48b48b1fe1e2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aae6efaf-587f-4596-a6ff-48b48b1fe1e2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jared\_P](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Jared\_P](https://discuss.elastic.co/u/Jared_P)\
**Post date:** [February 17, 2015, 9:31pm UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/5 "2015-02-17T21:31:57Z")

</div>

Also glad to hear someone else is having this problem. I was also really  
excited that they introduced this feature, I've just been having a really  
difficult time getting it to work.

So I just updated your script with the data that @ppf2 had in his Gist:

> **[shard cache script - Pastebin.com](https://pastebin.com/akJG6JQ1)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

Here's the results: [shard cache date filter - Pastebin.com](http://pastebin.com/RVDLAbMW)

I'm just at the point where I'm not sure if I'm doing something wrong, or  
if the bug was never successfully fixed.

On Tuesday, February 17, 2015 at 2:36:35 PM UTC-5, Luke Nezda wrote:

> Jared -
> 
> Silly me for assuming... No, I haven't actually tested with 1.4.3, it just  
> sounded the same. Did you try testing with @ppf2's gist  
> [query cache test · GitHub](https://gist.github.com/ppf2/bfa38b8284e09c0740ad) from  
> [Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) - it would be  
> particularly weird & disappointing if that was still broken too, but I  
> suppose mine could be different issue. I'm happy to hear _something_ on  
> this thread!
> 
> On Tuesday, February 17, 2015 at 12:57:21 PM UTC-6, Jared P wrote:
> 
> > Luke - I've been having this same problem as you originally posted. I  
> > just updated to Elasticsearch 1.4.3 and haven't seen any change of behavior  
> > when using a date range. In fact, it looks like the Gist you posted is  
> > still failing as it was for ES 1.4.2. Have you seen any changes since  
> > upgrading to 1.4.3?
> > 
> > On Tuesday, February 17, 2015 at 11:41:22 AM UTC-5, Luke Nezda wrote:
> > 
> > > Answering myself: this was reported as a bug several weeks later  
> > > [Shard query cache not populated when there is a range filter · Issue #9225 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/9225) and the fix  
> > > was just released via  
> > > [Queries are never cached when date math expressions are used (including exact dates) by jpountz · Pull Request #9269 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/9269) in 1.4.3. Do  
> > > es devs read this list? Is this the wrong venue for this kind of feedback?  
> > > I had a gist and everything.
> > > 
> > > On Friday, December 19, 2014 at 12:49:27 PM UTC-6, Luke Nezda wrote:
> > > 
> > > > I'm using Elasticsearch 1.4.2 and was excited about the new shard  
> > > > query cache  
> > > > [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-shard-query-cache.html),  
> > > > but I am surprised this simple terms aggregate doesn't seem to show up in  
> > > > the cache if I have a date range filter:  
> > > > [Agg query\_cache not working with date filter · GitHub](https://gist.github.com/nezda/c65dd66785d5f1e4dbd4) -- I'm not  
> > > > referencing `now` or anything, so this seems like a bug to me.
> > > > 
> > > > Please advise,
> > > > 
> > > > - Luke

--  
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/3cbd2031-0543-47c1-8449-34c94f916017%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3cbd2031-0543-47c1-8449-34c94f916017%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 2015, 8:51am UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/6 "2015-02-26T08:51:04Z")

</div>

[https://github.com/elasticsearch/elasticsearch/issues/9225](https://github.com/elasticsearch/elasticsearch/issues/9225) was reopened - apparently fix was lost in merge conflicts and seems there was no automatic test added to catch it.

--  
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/976e7f0a-4062-48b9-9f4b-ce0d3f70df8d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/976e7f0a-4062-48b9-9f4b-ce0d3f70df8d%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:29am UTC](https://discuss.elastic.co/t/shard-query-cache-not-working-for-aggregates-with-simple-date-range-filter/21335/7 "2017-07-06T00:29:55Z")

</div>


