# Using more than one key\_field for terms\_stats filter

**URL:** <https://discuss.elastic.co/t/using-more-than-one-key-field-for-terms-stats-filter/12171>\
**Category:** Elasticsearch\
**Created:** [May 29, 2013, 2:18pm UTC](https://discuss.elastic.co/t/using-more-than-one-key-field-for-terms-stats-filter/12171 "2013-05-29T14:18:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uri\_Agassi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uri_agassi/32/2304_2.png) [@Uri\_Agassi](https://discuss.elastic.co/u/Uri_Agassi)\
**Post date:** [May 29, 2013, 2:18pm UTC](https://discuss.elastic.co/t/using-more-than-one-key-field-for-terms-stats-filter/12171/1 "2013-05-29T14:18:06Z")

</div>

Say I have an index containing page view data on my site with country  
information, per page in my sight.  
To see how many page views I had per day, I can do the following query:

{  
"size": 0,  
"facets": {  
"daily": {  
"terms\_stats": {  
"key\_field": "date",  
"value\_field": "views"  
}  
}  
}  
}

To see how many page view I had per country, I can do the following query:

{  
"size": 0,  
"facets": {  
"daily": {  
"terms\_stats": {  
"key\_field": "country",  
"value\_field": "views"  
}  
}  
}  
}

Now say I want to make a query to see how many page views I had on my site \*per  
\*country \*per \*day, how do I do that?

I'd like the result to look something like this:

"2013-05-25", "US", 235642  
"2013-05-26", "US", 325219  
"2013-05-25", "DE", 125648  
"2013-05-26", "DE", 153942

etc..

--  
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:34am UTC](https://discuss.elastic.co/t/using-more-than-one-key-field-for-terms-stats-filter/12171/2 "2017-07-06T02:34:05Z")

</div>


