# Interaction between date\_histogram and filter on same field

**URL:** <https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359>\
**Category:** Elasticsearch\
**Created:** [July 9, 2012, 12:07pm UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359 "2012-07-09T12:07:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Fairs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_fairs/32/1205_2.png) [@Dan\_Fairs](https://discuss.elastic.co/u/Dan_Fairs)\
**Post date:** [July 9, 2012, 12:07pm UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359/1 "2012-07-09T12:07:48Z")

</div>

Hi,

I'm seeing something slightly odd when using a date\_histogram and a filter on the same field. When using both, the query results look fine, but I see errors in the ES log.

Here's the query:

[https://gist.github.com/2bdcbf74888b067257c8](https://gist.github.com/2bdcbf74888b067257c8)

Now - the output of the query does look correct. However, I see the following in the ES log:

[https://gist.github.com/bc644940577caab88e15](https://gist.github.com/bc644940577caab88e15)

It looks like ES is complaining that interaction.created\_at is an invalid field when building the date histogram facet - however, the results look absolutely fine (with some non-exhaustive testing).

If I don't include the range filters, then I don't get any errors in the log.

I have a mapping for this type that looks like this:

```
        'interaction.created_at': {
            'type': 'date',
            'format': 'EEE, dd MMM yyyy HH:mm:ss +0000'
        }

```

Can anyone tell me what's going on?

(Incidentally, the reason I've got two range filters rather than just one is that this is an early version of our code, just building a query naively based on parameters passed to it. I'll improve this in due course, assuming it's unrelated.)

This is ElasticSearch 0.19.8 running on OS X Lion (will be Ubuntu 12.04 in production).

Cheers,  
Dan

--  
Dan Fairs | [dan.fairs@gmail.com](mailto:dan.fairs@gmail.com) | @danfairs | [www.fezconsulting.com](http://www.fezconsulting.com)

---

<div class="post-metadata">

**Author:** ![Dan\_Fairs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_fairs/32/1205_2.png) [@Dan\_Fairs](https://discuss.elastic.co/u/Dan_Fairs)\
**Post date:** [July 9, 2012, 12:27pm UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359/2 "2012-07-09T12:27:13Z")

</div>

Sorry to reply to my own post.

> Here's the query:
> 
> [Example query · GitHub](https://gist.github.com/2bdcbf74888b067257c8)
> 
> Now - the output of the query does look correct. However, I see the following in the ES log:
> 
> [Traceback · GitHub](https://gist.github.com/bc644940577caab88e15)
> 
> It looks like ES is complaining that interaction.created\_at is an invalid field when building the date histogram facet - however, the results look absolutely fine (with some non-exhaustive testing).

I've just noticed that these are logged at DEBUG level, therefore feel ignorable. Is that right, or should I be worried about them?

## Cheers, Dan

Dan Fairs | [dan.fairs@gmail.com](mailto:dan.fairs@gmail.com) | @danfairs | [www.fezconsulting.com](http://www.fezconsulting.com)

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 9, 2012, 8:23pm UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359/3 "2012-07-09T20:23:17Z")

</div>

Hi Dan,

It looks like you are running this query across all indices in your cluster  
and a couple of indices (\_river and danfairs\_tweets\_for\_tx\_0000032048)  
don't have the field interaction.created\_at defined in their mappings. You  
might improve performance of your query by running it only on the indexes,  
that you really want to get data from.

Igor

On Monday, July 9, 2012 8:27:13 AM UTC-4, Dan Fairs wrote:

> Sorry to reply to my own post.
> 
> Here's the query:
> 
> [Example query · GitHub](https://gist.github.com/2bdcbf74888b067257c8)
> 
> Now - the output of the query does look correct. However, I see the  
> following in the ES log:
> 
> [Traceback · GitHub](https://gist.github.com/bc644940577caab88e15)
> 
> It looks like ES is complaining that interaction.created\_at is an invalid  
> field when building the date histogram facet - however, the results look  
> absolutely fine (with some non-exhaustive testing).
> 
> I've just noticed that these are logged at DEBUG level, therefore feel  
> ignorable. Is that right, or should I be worried about them?
> 
> ## Cheers, Dan
> 
> Dan Fairs | [dan.fairs@gmail.com](mailto:dan.fairs@gmail.com) | @danfairs | [www.fezconsulting.com](http://www.fezconsulting.com)

---

<div class="post-metadata">

**Author:** ![Dan\_Fairs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_fairs/32/1205_2.png) [@Dan\_Fairs](https://discuss.elastic.co/u/Dan_Fairs)\
**Post date:** [July 9, 2012, 10:05pm UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359/4 "2012-07-09T22:05:15Z")

</div>

Hi Igor

> It looks like you are running this query across all indices in your cluster and a couple of indices (\_river and danfairs\_tweets\_for\_tx\_0000032048) don't have the field interaction.created\_at defined in their mappings. You might improve performance of your query by running it only on the indexes, that you really want to get data from.

Yes - you're quite right, I noticed this when comparing the shards that were erroring with the shards that were actually hosting the data. As you suggested, I restricted the query to run only on the relevant indices, and I no longer get the log messages.

Thanks for taking a look!

## Cheers, Dan

Dan Fairs | [dan.fairs@gmail.com](mailto:dan.fairs@gmail.com) | @danfairs | [www.fezconsulting.com](http://www.fezconsulting.com)

---

<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, 3:20am UTC](https://discuss.elastic.co/t/interaction-between-date-histogram-and-filter-on-same-field/8359/5 "2017-07-06T03:20:52Z")

</div>


