Post Filter access aggregation values

Hi there
I need help to understand how to run post filter scripts to show only results with cardinality > 2.
{ "aggs" : { "products_items" : { "term": { "field": "product" } },
"aggs" : { "distinct_pricing" : { "cardinality" : { "field" : "price_types" } } },
"post_filter": {"script": {"script": "distinct_pricing[price_type].value > 2 "}}} } } }

Basically with we have products_items with many pricing types ;eg for VIP customers, VVIP customers & normal customers then we are interested to show only those items.

product_items price_type
001 VIP
001 VVIP
001 ORD
002 ORD
003 VIP
003 VVIP
004 VIP
005 ORD
005 VIP

Appreciate any help guidance.

Cheers

post_filter is only about top hits, not aggregations. What you are looking after is the bucket selector aggregation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html

Adrien Grand
Thank you very much, Finally got it working -
I have pasted the sample query hopefully will be useful to others who encounter such a problem.
{
"aggs": {"ID1": {"terms": {"field": "cars"},
"aggs": {"ID2": {"cardinality": {"field": "roadaccessed"}},
"bucketfilter": {"bucket_selector": { "buckets_path" : { "cnt":"ID2"}, "script": "cnt>5" }}}}} }

This will give you a list of cars that have accessed more than 5 roads