# Histogram Aggregation

**URL:** https://discuss.elastic.co/t/histogram-aggregation/42826
**Category:** Discussions en français
**Created:** [February 26, 2016, 8:45am UTC](https://discuss.elastic.co/t/histogram-aggregation/42826 "2016-02-26T08:45:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![patou](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@patou](https://discuss.elastic.co/u/patou)
#### Post date: [February 26, 2016, 8:45am UTC](https://discuss.elastic.co/t/histogram-aggregation/42826/1 "2016-02-26T08:45:32Z")

</div>

bonjour

mes docs :

"periode": [  
{ "start": "2015-09-07T09:00:00.000Z","end": "2015-09-07T10:15:00.000Z"},  
{ "start": "2015-09-07T11:15:00.000Z","end": "2015-09-07T12:30:00.000Z"},  
]  
"periode": [  
{ "start": "2015-09-07T09:00:00.000Z","end": "2015-09-07T10:15:00.000Z"},  
]

mon besoin : une Date Histogram Aggregation pour compter les documents par interval mais avec la condition suivante : champ start avant l'intervalle etchamp end après intervalle.  
dans l’exemple, dans l'intervalle 09:15-09h30 (interval = 15 m) j'ai 3 docs.

je peux faire un count sur chaque intervalle avec un filter mais la requête est très longue et pénible à écrire, je cherche une astuce.

cdt  
patrick

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 26, 2016, 3:50pm UTC](https://discuss.elastic.co/t/histogram-aggregation/42826/2 "2016-02-26T15:50:09Z")

</div>

En effet, à part le filter, je n'ai pas trop d'idée supplémentaire. Peut-être un [script](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/search-aggregations-bucket-datehistogram-aggregation.html#_scripts) ?

---

<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:49pm UTC](https://discuss.elastic.co/t/histogram-aggregation/42826/3 "2017-07-06T13:49:20Z")

</div>


