# ES 5.2: How select aggregation max with filter value

**URL:** <https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441>\
**Category:** Elasticsearch\
**Created:** [February 8, 2017, 10:35pm UTC](https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441 "2017-02-08T22:35:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pashkevich\_Aleksandr](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Pashkevich\_Aleksandr](https://discuss.elastic.co/u/Pashkevich_Aleksandr)\
**Post date:** [February 8, 2017, 10:35pm UTC](https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441/1 "2017-02-08T22:35:28Z")

</div>

Hello. Sorry for my English  
Me need select 4 aggregation for terms  
1 agg it's max value field price, where filter is\_new:true  
2 agg it's min value field price, where filter is\_new:true

3 agg it's max value field price, where filter is\_new:false  
4 agg it's min value field price, where filter is\_new:false  
I tried this query, but this dont work:

```
"aggs" : {
				"p_product" : {
					"terms" : { "field" : "pr_article_search" }
					,"aggs" : {
						"max_price" : { "max" : { "field" : "pr_price_calc" }, "filter": {"term": {"pr_is_new": "1"} },
						"min_price" : { "min" : { "field" : "pr_price_calc" }, "filter": {"term": {"pr_is_new": "1"} },
						
					}
				}
				 
			}

```

P.s. and i try use google before create this topic

---

<div class="post-metadata">

**Author:** ![wenpos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wenpos/32/15326_2.png) [@wenpos](https://discuss.elastic.co/u/wenpos)\
**Post date:** [February 9, 2017, 12:07am UTC](https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441/2 "2017-02-09T00:07:58Z")

</div>

refer to [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filter-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-bucket-filter-aggregation.html)

---

<div class="post-metadata">

**Author:** ![Pashkevich\_Aleksandr](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@Pashkevich\_Aleksandr](https://discuss.elastic.co/u/Pashkevich_Aleksandr)\
**Post date:** [February 9, 2017, 12:15am UTC](https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441/3 "2017-02-09T00:15:19Z")

</div>

Big thank you.

---

<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:** [March 9, 2017, 12:15am UTC](https://discuss.elastic.co/t/es-5-2-how-select-aggregation-max-with-filter-value/74441/4 "2017-03-09T00:15:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
