# Create aggregated table with elasticsearch like MySQL

**URL:** <https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359>\
**Category:** Elasticsearch\
**Created:** [June 11, 2013, 10:17am UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359 "2013-06-11T10:17:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remy\_Turpin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/remy_turpin/32/2277_2.png) [@Remy\_Turpin](https://discuss.elastic.co/u/Remy_Turpin)\
**Post date:** [June 11, 2013, 10:17am UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359/1 "2013-06-11T10:17:55Z")

</div>

Hello,

I'm new and I like more and more elasticsearch.  
I'm working on a statistic dashboard actually on MySQL whose I'm trying to  
transform on elasticsearch.

That's my index :

{  
'phone\_number': '0123456789',  
'status': 'Busy',  
'site\_name': 'toto',  
'call\_duration': 82,  
'url': '[http://localhost/test](http://localhost/test)',  
'browser\_version': '23.0.1271.97',  
'date': datetime.datetime(2013, 6, 1, 14, 12, 42),  
'price': 1.1,  
'browser': 'Google Chrome'  
} {  
'phone\_number': '0223456789',  
'status': 'HangUp',  
'site\_name': 'pipo',  
'call\_duration': 100,  
'url': '[http://localhost/index](http://localhost/index)',  
'browser\_version': '23.0.1271.97',  
'date': datetime.datetime(2013, 6, 2, 14, 12, 42),  
'price': 1.5,  
'browser': 'Google Chrome'  
} {  
'phone\_number': '0333456789',  
'status': 'HangUp',  
'site\_name': 'pouet',  
'call\_duration': 82,  
'url': '[http://localhost](http://localhost)',  
'browser\_version': '23.0.1271.97',  
'date': datetime.datetime(2013, 6, 2, 16, 12, 42),  
'price': 1.1,  
'browser': 'Google Chrome'  
} {  
'phone\_number': '0443456789',  
'status': 'Busy',  
'site\_name': 'tutu',  
'call\_duration': 82,  
'url': '[http://localhost](http://localhost)',  
'browser\_version': '23.0.1271.97',  
'date': datetime.datetime(2013, 6, 3, 12, 12, 42),  
'price': 1.1,  
'browser': 'Google Chrome'  
} {  
'phone\_number': '0553456789',  
'status': 'Invalid',  
'site\_name': 'tutu',  
'call\_duration': 50,  
'url': '[http://localhost](http://localhost)',  
'browser\_version': '23.0.1271.97',  
'date': datetime.datetime(2013, 6, 3, 17, 12, 42),  
'price': 1.1,  
'browser': 'Google Chrome'  
}

I would like create a table like that :  
DATE | CALL\_DURATION | PRICE | _Status HangUp_ | Status busy | Status  
Invalid

2013-06-03 | 132 | 2.2 | 0 | 1 | 1  
2013-06-02 | 182 | 2.6 | _2_ | 0 |0

I build this query :  
{  
'query': {  
'filtered': {  
'filter': {  
'range': {  
'date': {  
'to': datetime.datetime(2013, 6, 3, 0, 0),  
'include\_upper': False,  
'from': datetime.datetime(2013, 6, 1, 0, 0)  
}  
}  
},  
'query': {  
'match\_all': {}  
}  
}  
},  
'facets': {  
'date\_facet\_price': {  
'date\_histogram': {  
'value\_field': 'price',  
'interval': 'day',  
'key\_field': 'date'  
}  
},  
'date\_facet\_call': {  
'date\_histogram': {  
'value\_field': 'call\_duration',  
'interval': 'day',  
'key\_field': 'date'  
}  
}  
}  
}

I've got this result :

{

- date\_facet\_price:  
{
  - \_type: "date\_histogram",
  - 
## entries: [

## { - count: 8149, - total: 8680.499999999962, - total\_count: 8149, - min: 0, - max: 6.03, - time: 1370044800000, - mean: 1.0652227267149297 },

## { - count: 2325, - total: 2374.9300000000003, - total\_count: 2325, - min: 0, - max: 6.33, - time: 1370131200000, - mean: 1.0214752688172044 },
{  
- count: 5199,  
- total: 5658.63999999999,  
- total\_count: 5199,  
- min: 0,  
- max: 5,  
- time: 1370217600000,  
- mean: 1.0884093094825908  
}  
]  
},

- date\_facet\_call:  
{
  - \_type: "date\_histogram",
  - 
## entries: [

## { - count: 8149, - total: 1, - total\_count: 8149, - min: 0, - max: 4, - time: 1370044800000, - mean: 0.011657872131549884 },

## { - count: 2325, - total: 2, - total\_count: 2325, - min: 0, - max: 1, - time: 1370131200000, - mean: 0.01032258064516129 },
{  
- count: 5199,  
- total: 3,  
- total\_count: 5199,  
- min: 50,  
- max: 100,  
- time: 1370217600000,  
- mean: 0.0044239276783996926  
}  
]  
},

I'would like to recover the status distribution by day, like mean of price  
for example :.

- status:  
{
  - \_type: "terms",
  - total: 15673,
  - 
## terms: [

## { - count: 2, - term: "HangUp", _time_: 1370131200000 },

## { - count: 1, - term: "Busy", _time_: 1370131200000 },

## { - count: 3, - term: "NoAnswer", _time_: 1370131200000 },
{  
- count: 1,  
- term: "Invalid"  
}  
],
  - other: 0,
  - missing: 0  
},

I hope I was clear.

Thank you for read.

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [June 12, 2013, 2:56pm UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359/2 "2013-06-12T14:56:07Z")

</div>

Currently hierarchal facets are not supported. Hopefully they will be in  
the future. The only solution I can think of is to execute another faceted  
query with facets on status for each individual day.

--  
Ivan

On Tue, Jun 11, 2013 at 3:17 AM, Rémy Turpin [remy.turpin@gmail.com](mailto:remy.turpin@gmail.com) wrote:

> Hello,
> 
> I'm new and I like more and more elasticsearch.  
> I'm working on a statistic dashboard actually on MySQL whose I'm trying to  
> transform on elasticsearch.
> 
> That's my index :
> 
> {  
> 'phone\_number': '0123456789',  
> 'status': 'Busy',  
> 'site\_name': 'toto',  
> 'call\_duration': 82,  
> 'url': '[http://localhost/test](http://localhost/test)',  
> 'browser\_version': '23.0.1271.97',  
> 'date': datetime.datetime(2013, 6, 1, 14, 12, 42),  
> 'price': 1.1,  
> 'browser': 'Google Chrome'  
> } {  
> 'phone\_number': '0223456789',  
> 'status': 'HangUp',  
> 'site\_name': 'pipo',  
> 'call\_duration': 100,  
> 'url': '[http://localhost/index](http://localhost/index)',  
> 'browser\_version': '23.0.1271.97',  
> 'date': datetime.datetime(2013, 6, 2, 14, 12, 42),  
> 'price': 1.5,  
> 'browser': 'Google Chrome'  
> } {  
> 'phone\_number': '0333456789',  
> 'status': 'HangUp',  
> 'site\_name': 'pouet',  
> 'call\_duration': 82,  
> 'url': '[http://localhost](http://localhost)',  
> 'browser\_version': '23.0.1271.97',  
> 'date': datetime.datetime(2013, 6, 2, 16, 12, 42),  
> 'price': 1.1,  
> 'browser': 'Google Chrome'  
> } {  
> 'phone\_number': '0443456789',  
> 'status': 'Busy',  
> 'site\_name': 'tutu',  
> 'call\_duration': 82,  
> 'url': '[http://localhost](http://localhost)',  
> 'browser\_version': '23.0.1271.97',  
> 'date': datetime.datetime(2013, 6, 3, 12, 12, 42),  
> 'price': 1.1,  
> 'browser': 'Google Chrome'  
> } {  
> 'phone\_number': '0553456789',  
> 'status': 'Invalid',  
> 'site\_name': 'tutu',  
> 'call\_duration': 50,  
> 'url': '[http://localhost](http://localhost)',  
> 'browser\_version': '23.0.1271.97',  
> 'date': datetime.datetime(2013, 6, 3, 17, 12, 42),  
> 'price': 1.1,  
> 'browser': 'Google Chrome'  
> }
> 
> I would like create a table like that :  
> DATE | CALL\_DURATION | PRICE | _Status HangUp_ | Status busy | Status  
> Invalid
> 
> 2013-06-03 | 132 | 2.2 | 0 | 1 | 1  
> 2013-06-02 | 182 | 2.6 | _2_ | 0 |0
> 
> I build this query :  
> {  
> 'query': {  
> 'filtered': {  
> 'filter': {  
> 'range': {  
> 'date': {  
> 'to': datetime.datetime(2013, 6, 3, 0, 0),  
> 'include\_upper': False,  
> 'from': datetime.datetime(2013, 6, 1, 0, 0)  
> }  
> }  
> },  
> 'query': {  
> 'match\_all': {}  
> }  
> }  
> },  
> 'facets': {  
> 'date\_facet\_price': {  
> 'date\_histogram': {  
> 'value\_field': 'price',  
> 'interval': 'day',  
> 'key\_field': 'date'  
> }  
> },  
> 'date\_facet\_call': {  
> 'date\_histogram': {  
> 'value\_field': 'call\_duration',  
> 'interval': 'day',  
> 'key\_field': 'date'  
> }  
> }  
> }  
> }
> 
> I've got this result :
> 
> {
> 
> - date\_facet\_price:  
> {
> - \_type: "date\_histogram",
> - 
> ## entries: [
> 
> ## { - count: 8149, - total: 8680.499999999962, - total\_count: 8149, - min: 0, - max: 6.03, - time: 1370044800000, - mean: 1.0652227267149297 },
> 
> ## { - count: 2325, - total: 2374.9300000000003, - total\_count: 2325, - min: 0, - max: 6.33, - time: 1370131200000, - mean: 1.0214752688172044 },
> {  
> - count: 5199,  
> - total: 5658.63999999999,  
> - total\_count: 5199,  
> - min: 0,  
> - max: 5,  
> - time: 1370217600000,  
> - mean: 1.0884093094825908  
> }  
> ]  
> },
> 
> - date\_facet\_call:  
> {
> - \_type: "date\_histogram",
> - 
> ## entries: [
> 
> ## { - count: 8149, - total: 1, - total\_count: 8149, - min: 0, - max: 4, - time: 1370044800000, - mean: 0.011657872131549884 },
> 
> ## { - count: 2325, - total: 2, - total\_count: 2325, - min: 0, - max: 1, - time: 1370131200000, - mean: 0.01032258064516129 },
> {  
> - count: 5199,  
> - total: 3,  
> - total\_count: 5199,  
> - min: 50,  
> - max: 100,  
> - time: 1370217600000,  
> - mean: 0.0044239276783996926  
> }  
> ]  
> },
> 
> I'would like to recover the status distribution by day, like mean of price  
> for example :.
> 
> - status:  
> {
> - \_type: "terms",
> - total: 15673,
> - 
> ## terms: [
> 
> ## { - count: 2, - term: "HangUp", _time_: 1370131200000 },
> 
> ## { - count: 1, - term: "Busy", _time_: 1370131200000 },
> 
> ## { - count: 3, - term: "NoAnswer", _time_: 1370131200000 },
> {  
> - count: 1,  
> - term: "Invalid"  
> }  
> ],
> - other: 0,
> - missing: 0  
> },
> 
> I hope I was clear.
> 
> Thank you for read.
> 
> --  
> 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).

--  
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:** ![Remy\_Turpin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/remy_turpin/32/2277_2.png) [@Remy\_Turpin](https://discuss.elastic.co/u/Remy_Turpin)\
**Post date:** [June 13, 2013, 4:39pm UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359/3 "2013-06-13T16:39:44Z")

</div>

OK thank's, we know when this fonctionnality will be implemented ?

Le mercredi 12 juin 2013 16:56:07 UTC+2, Ivan Brusic a écrit :

> Currently hierarchal facets are not supported. Hopefully they will be in  
> the future. The only solution I can think of is to execute another faceted  
> query with facets on status for each individual day.
> 
> --  
> Ivan
> 
> On Tue, Jun 11, 2013 at 3:17 AM, Rémy Turpin \<[remy....@gmail.com](mailto:remy....@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hello,
> > 
> > I'm new and I like more and more elasticsearch.  
> > I'm working on a statistic dashboard actually on MySQL whose I'm trying  
> > to transform on elasticsearch.
> > 
> > That's my index :
> > 
> > {  
> > 'phone\_number': '0123456789',  
> > 'status': 'Busy',  
> > 'site\_name': 'toto',  
> > 'call\_duration': 82,  
> > 'url': '[http://localhost/test](http://localhost/test)',  
> > 'browser\_version': '23.0.1271.97',  
> > 'date': datetime.datetime(2013, 6, 1, 14, 12, 42),  
> > 'price': 1.1,  
> > 'browser': 'Google Chrome'  
> > } {  
> > 'phone\_number': '0223456789',  
> > 'status': 'HangUp',  
> > 'site\_name': 'pipo',  
> > 'call\_duration': 100,  
> > 'url': '[http://localhost/index](http://localhost/index)',  
> > 'browser\_version': '23.0.1271.97',  
> > 'date': datetime.datetime(2013, 6, 2, 14, 12, 42),  
> > 'price': 1.5,  
> > 'browser': 'Google Chrome'  
> > } {  
> > 'phone\_number': '0333456789',  
> > 'status': 'HangUp',  
> > 'site\_name': 'pouet',  
> > 'call\_duration': 82,  
> > 'url': '[http://localhost](http://localhost)',  
> > 'browser\_version': '23.0.1271.97',  
> > 'date': datetime.datetime(2013, 6, 2, 16, 12, 42),  
> > 'price': 1.1,  
> > 'browser': 'Google Chrome'  
> > } {  
> > 'phone\_number': '0443456789',  
> > 'status': 'Busy',  
> > 'site\_name': 'tutu',  
> > 'call\_duration': 82,  
> > 'url': '[http://localhost](http://localhost)',  
> > 'browser\_version': '23.0.1271.97',  
> > 'date': datetime.datetime(2013, 6, 3, 12, 12, 42),  
> > 'price': 1.1,  
> > 'browser': 'Google Chrome'  
> > } {  
> > 'phone\_number': '0553456789',  
> > 'status': 'Invalid',  
> > 'site\_name': 'tutu',  
> > 'call\_duration': 50,  
> > 'url': '[http://localhost](http://localhost)',  
> > 'browser\_version': '23.0.1271.97',  
> > 'date': datetime.datetime(2013, 6, 3, 17, 12, 42),  
> > 'price': 1.1,  
> > 'browser': 'Google Chrome'  
> > }
> > 
> > I would like create a table like that :  
> > DATE | CALL\_DURATION | PRICE | _Status HangUp_ | Status busy | Status  
> > Invalid
> > 
> > 2013-06-03 | 132 | 2.2 | 0 | 1 | 1  
> > 2013-06-02 | 182 | 2.6 | _2_ | 0 |0
> > 
> > I build this query :  
> > {  
> > 'query': {  
> > 'filtered': {  
> > 'filter': {  
> > 'range': {  
> > 'date': {  
> > 'to': datetime.datetime(2013, 6, 3, 0, 0),  
> > 'include\_upper': False,  
> > 'from': datetime.datetime(2013, 6, 1, 0, 0)  
> > }  
> > }  
> > },  
> > 'query': {  
> > 'match\_all': {}  
> > }  
> > }  
> > },  
> > 'facets': {  
> > 'date\_facet\_price': {  
> > 'date\_histogram': {  
> > 'value\_field': 'price',  
> > 'interval': 'day',  
> > 'key\_field': 'date'  
> > }  
> > },  
> > 'date\_facet\_call': {  
> > 'date\_histogram': {  
> > 'value\_field': 'call\_duration',  
> > 'interval': 'day',  
> > 'key\_field': 'date'  
> > }  
> > }  
> > }  
> > }
> > 
> > I've got this result :
> > 
> > {
> > 
> > - date\_facet\_price:  
> > {
> > - \_type: "date\_histogram",
> > - 
> > ## entries: [
> > 
> > ## { - count: 8149, - total: 8680.499999999962, - total\_count: 8149, - min: 0, - max: 6.03, - time: 1370044800000, - mean: 1.0652227267149297 },
> > 
> > ## { - count: 2325, - total: 2374.9300000000003, - total\_count: 2325, - min: 0, - max: 6.33, - time: 1370131200000, - mean: 1.0214752688172044 },
> > {  
> > - count: 5199,  
> > - total: 5658.63999999999,  
> > - total\_count: 5199,  
> > - min: 0,  
> > - max: 5,  
> > - time: 1370217600000,  
> > - mean: 1.0884093094825908  
> > }  
> > ]  
> > },
> > 
> > - date\_facet\_call:  
> > {
> > - \_type: "date\_histogram",
> > - 
> > ## entries: [
> > 
> > ## { - count: 8149, - total: 1, - total\_count: 8149, - min: 0, - max: 4, - time: 1370044800000, - mean: 0.011657872131549884 },
> > 
> > ## { - count: 2325, - total: 2, - total\_count: 2325, - min: 0, - max: 1, - time: 1370131200000, - mean: 0.01032258064516129 },
> > {  
> > - count: 5199,  
> > - total: 3,  
> > - total\_count: 5199,  
> > - min: 50,  
> > - max: 100,  
> > - time: 1370217600000,  
> > - mean: 0.0044239276783996926  
> > }  
> > ]  
> > },
> > 
> > I'would like to recover the status distribution by day, like mean of  
> > price for example :.
> > 
> > - status:  
> > {
> > - \_type: "terms",
> > - total: 15673,
> > - 
> > ## terms: [
> > 
> > ## { - count: 2, - term: "HangUp", _time_: 1370131200000 },
> > 
> > ## { - count: 1, - term: "Busy", _time_: 1370131200000 },
> > 
> > ## { - count: 3, - term: "NoAnswer", _time_: 1370131200000 },
> > {  
> > - count: 1,  
> > - term: "Invalid"  
> > }  
> > ],
> > - other: 0,
> > - missing: 0  
> > },
> > 
> > I hope I was clear.
> > 
> > Thank you for read.
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [June 13, 2013, 7:28pm UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359/4 "2013-06-13T19:28:49Z")

</div>

Read more in this issue:

> <https://github.com/elastic/elasticsearch/issues/1076>
>
> This seems to be a popular request. This feature would allow hierarchical facet…s on fields that are not necessarily numeric, thus allowing faceting that looks like this, for example:
> 
> Media Type Facets:
> \- twitter (20)
> - source: foo (12)
> - source: bar (8)
> \- facebook (14)
> - source: foo (10)
> - source: bar (4)

On Thu, Jun 13, 2013 at 9:39 AM, Rémy Turpin [remy.turpin@gmail.com](mailto:remy.turpin@gmail.com) wrote:

> OK thank's, we know when this fonctionnality will be implemented ?
> 
> Le mercredi 12 juin 2013 16:56:07 UTC+2, Ivan Brusic a écrit :
> 
> > Currently hierarchal facets are not supported. Hopefully they will be in  
> > the future. The only solution I can think of is to execute another faceted  
> > query with facets on status for each individual day.
> > 
> > --  
> > Ivan
> > 
> > On Tue, Jun 11, 2013 at 3:17 AM, Rémy Turpin [remy....@gmail.com](mailto:remy....@gmail.com) wrote:
> > 
> > > Hello,
> > > 
> > > I'm new and I like more and more elasticsearch.  
> > > I'm working on a statistic dashboard actually on MySQL whose I'm trying  
> > > to transform on elasticsearch.
> > > 
> > > That's my index :
> > > 
> > > {  
> > > 'phone\_number': '0123456789',  
> > > 'status': 'Busy',  
> > > 'site\_name': 'toto',  
> > > 'call\_duration': 82,  
> > > 'url': '[http://localhost/test](http://localhost/test)',  
> > > 'browser\_version': '23.0.1271.97',  
> > > 'date': datetime.datetime(2013, 6, 1, 14, 12, 42),  
> > > 'price': 1.1,  
> > > 'browser': 'Google Chrome'  
> > > } {  
> > > 'phone\_number': '0223456789',  
> > > 'status': 'HangUp',  
> > > 'site\_name': 'pipo',  
> > > 'call\_duration': 100,  
> > > 'url': '[http://localhost/index](http://localhost/index)',  
> > > 'browser\_version': '23.0.1271.97',  
> > > 'date': datetime.datetime(2013, 6, 2, 14, 12, 42),  
> > > 'price': 1.5,  
> > > 'browser': 'Google Chrome'  
> > > } {  
> > > 'phone\_number': '0333456789',  
> > > 'status': 'HangUp',  
> > > 'site\_name': 'pouet',  
> > > 'call\_duration': 82,  
> > > 'url': '[http://localhost](http://localhost)',  
> > > 'browser\_version': '23.0.1271.97',  
> > > 'date': datetime.datetime(2013, 6, 2, 16, 12, 42),  
> > > 'price': 1.1,  
> > > 'browser': 'Google Chrome'  
> > > } {  
> > > 'phone\_number': '0443456789',  
> > > 'status': 'Busy',  
> > > 'site\_name': 'tutu',  
> > > 'call\_duration': 82,  
> > > 'url': '[http://localhost](http://localhost)',  
> > > 'browser\_version': '23.0.1271.97',  
> > > 'date': datetime.datetime(2013, 6, 3, 12, 12, 42),  
> > > 'price': 1.1,  
> > > 'browser': 'Google Chrome'  
> > > } {  
> > > 'phone\_number': '0553456789',  
> > > 'status': 'Invalid',  
> > > 'site\_name': 'tutu',  
> > > 'call\_duration': 50,  
> > > 'url': '[http://localhost](http://localhost)',  
> > > 'browser\_version': '23.0.1271.97',  
> > > 'date': datetime.datetime(2013, 6, 3, 17, 12, 42),  
> > > 'price': 1.1,  
> > > 'browser': 'Google Chrome'  
> > > }
> > > 
> > > I would like create a table like that :  
> > > DATE | CALL\_DURATION | PRICE | _Status HangUp_ | Status busy | Status  
> > > Invalid
> > > 
> > > 2013-06-03 | 132 | 2.2 | 0 | 1 | 1  
> > > 2013-06-02 | 182 | 2.6 | _2_ | 0 |0
> > > 
> > > I build this query :  
> > > {  
> > > 'query': {  
> > > 'filtered': {  
> > > 'filter': {  
> > > 'range': {  
> > > 'date': {  
> > > 'to': datetime.datetime(2013, 6, 3, 0, 0),  
> > > 'include\_upper': False,  
> > > 'from': datetime.datetime(2013, 6, 1, 0, 0)  
> > > }  
> > > }  
> > > },  
> > > 'query': {  
> > > 'match\_all': {}  
> > > }  
> > > }  
> > > },  
> > > 'facets': {  
> > > 'date\_facet\_price': {  
> > > 'date\_histogram': {  
> > > 'value\_field': 'price',  
> > > 'interval': 'day',  
> > > 'key\_field': 'date'  
> > > }  
> > > },  
> > > 'date\_facet\_call': {  
> > > 'date\_histogram': {  
> > > 'value\_field': 'call\_duration',  
> > > 'interval': 'day',  
> > > 'key\_field': 'date'  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > I've got this result :
> > > 
> > > {
> > > 
> > > - date\_facet\_price:  
> > > {
> > > - \_type: "date\_histogram",
> > > - 
> > > ## entries: [
> > > 
> > > ## { - count: 8149, - total: 8680.499999999962, - total\_count: 8149, - min: 0, - max: 6.03, - time: 1370044800000, - mean: 1.0652227267149297 },
> > > 
> > > ## { - count: 2325, - total: 2374.9300000000003, - total\_count: 2325, - min: 0, - max: 6.33, - time: 1370131200000, - mean: 1.0214752688172044 },
> > > {  
> > > - count: 5199,  
> > > - total: 5658.63999999999,  
> > > - total\_count: 5199,  
> > > - min: 0,  
> > > - max: 5,  
> > > - time: 1370217600000,  
> > > - mean: 1.0884093094825908  
> > > }  
> > > ]  
> > > },
> > > 
> > > - date\_facet\_call:  
> > > {
> > > - \_type: "date\_histogram",
> > > - 
> > > ## entries: [
> > > 
> > > ## { - count: 8149, - total: 1, - total\_count: 8149, - min: 0, - max: 4, - time: 1370044800000, - mean: 0.011657872131549884 },
> > > 
> > > ## { - count: 2325, - total: 2, - total\_count: 2325, - min: 0, - max: 1, - time: 1370131200000, - mean: 0.01032258064516129 },
> > > {  
> > > - count: 5199,  
> > > - total: 3,  
> > > - total\_count: 5199,  
> > > - min: 50,  
> > > - max: 100,  
> > > - time: 1370217600000,  
> > > - mean: 0.0044239276783996926  
> > > }  
> > > ]  
> > > },
> > > 
> > > I'would like to recover the status distribution by day, like mean of  
> > > price for example :.
> > > 
> > > - status:  
> > > {
> > > - \_type: "terms",
> > > - total: 15673,
> > > - 
> > > ## terms: [
> > > 
> > > ## { - count: 2, - term: "HangUp", _time_: 1370131200000 },
> > > 
> > > ## { - count: 1, - term: "Busy", _time_: 1370131200000 },
> > > 
> > > ## { - count: 3, - term: "NoAnswer", _time_: 1370131200000 },
> > > {  
> > > - count: 1,  
> > > - term: "Invalid"  
> > > }  
> > > ],
> > > - other: 0,
> > > - missing: 0  
> > > },
> > > 
> > > I hope I was clear.
> > > 
> > > Thank you for read.
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > 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).

--  
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:31am UTC](https://discuss.elastic.co/t/create-aggregated-table-with-elasticsearch-like-mysql/12359/5 "2017-07-06T02:31:19Z")

</div>


