Elasticsearch bucket aggreation with filters on returned buckets

I have posted a question on Stack overflow regarding the problem. Here is the link http://stackoverflow.com/questions/33873625/how-do-we-bucket-aggregate-only-on-the-matched-prefix-on-elasticsearch

Can anyone please help me with the problem?

I suppose the "include" feature of terms aggs would do the job? https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values_2

Thanks. That was it.