Apply filter in the right way.
Merge pull request #1 from kotrakrishna/master

Apply filter in the right way such that the query and aggregations happen on filtered set