I got two ways to aggs my data.
First, i filter mysql data and aggs it
Second ,i aggs data which is filtered in aggs. as below:
I found different result and I don't know why.
Anyone can explain it ?
From the Docs
By default, aggregations operate in the same scope as the query. Put another way, aggregations are calculated on the set of documents that match your query.
so in the first case, you are getting documents which match your criteria of "site_id" : 1167639
and then aggregation
is performed on those documents.
In the second case, you have not specified any query so by default it is match_all
query and you get back all the documents in your hits
which is 65773792. Then you use filter to narrow down your aggregation criteria.