# DateHistogramFacet, removing duplicates

**URL:** <https://discuss.elastic.co/t/datehistogramfacet-removing-duplicates/12827>\
**Category:** Elasticsearch\
**Created:** [July 17, 2013, 2:05pm UTC](https://discuss.elastic.co/t/datehistogramfacet-removing-duplicates/12827 "2013-07-17T14:05:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajses](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ajses](https://discuss.elastic.co/u/ajses)\
**Post date:** [July 17, 2013, 2:05pm UTC](https://discuss.elastic.co/t/datehistogramfacet-removing-duplicates/12827/1 "2013-07-17T14:05:42Z")

</div>

Hi!

I have an ES index of documents culled from products with unique serial numbers reporting phoning home, along with the timestamp of when they reported and a bunch of other data that I'd like to report on:

{ 'timestamp': whatevs, 'serial': '123', ... }, etc...

A problem is that sometimes the product will phone home more than once a week, if for example it was rebooted.

My aim is to construct an ES query, returning a DateHistogramFacet of matches per month or per quarter, where I would like at most one unique serial number to be counted per week, thus if a particular product happens to report multiple times a week, it contributes at most once to the total count. Essentially, removing duplicate entries where duplicate is defined as the same serial number having two json documents within the same 7 day period.

Is there an easy way to accomplish this within ES?

Thanks!  
A.

---

<div class="post-metadata">

**Author:** ![Eric\_Charles\_GMail](https://avatars.discourse-cdn.com/v4/letter/e/7ea924/32.png) [@Eric\_Charles\_GMail](https://discuss.elastic.co/u/Eric_Charles_GMail)\
**Post date:** [July 17, 2013, 3:22pm UTC](https://discuss.elastic.co/t/datehistogramfacet-removing-duplicates/12827/2 "2013-07-17T15:22:39Z")

</div>

Did you try the distinct\_date\_histogram of elasticsearch-timefacets-plugin?

> **[GitHub - crate/elasticsearch-timefacets-plugin: Elasticsearch Timebased Facets](https://github.com/crate/elasticsearch-timefacets-plugin)**
>
> Elasticsearch Timebased Facets. Contribute to crate/elasticsearch-timefacets-plugin development by creating an account on GitHub.

On 17/07/2013 15:05, ajses wrote:

> Hi!
> 
> I have an ES index of documents culled from products with unique serial  
> numbers reporting phoning home, along with the timestamp of when they  
> reported and a bunch of other data that I'd like to report on:
> 
> { 'timestamp': whatevs, 'serial': '123', ... }, etc...
> 
> A problem is that sometimes the product will phone home more than once a  
> week, if for example it was rebooted.
> 
> My aim is to construct an ES query, returning a DateHistogramFacet of  
> matches per month or per quarter, where I would like at most one unique  
> serial number to be counted per week, thus if a particular product happens  
> to report multiple times a week, it contributes at most once to the total  
> count. Essentially, removing duplicate entries where duplicate is defined as  
> the same serial number having two json documents within the same 7 day  
> period.
> 
> Is there an easy way to accomplish this within ES?
> 
> Thanks!  
> A.
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/DateHistogramFacet-removing-duplicates-tp4038261.html](http://elasticsearch-users.115913.n3.nabble.com/DateHistogramFacet-removing-duplicates-tp4038261.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:25am UTC](https://discuss.elastic.co/t/datehistogramfacet-removing-duplicates/12827/3 "2017-07-06T02:25:56Z")

</div>


