Different result from search and aggregation of that search

Hi,
I'm getting different results from a search for documents and the same search done with aggregations.
Here are the searches I'm using:
Search for documents:

{ "query": {"multi_match" : {"query": "whatever", "fields": [ "name^5", "company", "description" ]}}, "from": 0,"size": 12}

Same search, aggregated:

{ "fields": ["categories.raw"], "query": {"filtered" : {"query": {"multi_match" : {"query": "whatever", "fields": [ "name^5", "company", "description" ] }}}} , "aggs" : {"categories" : {"terms" : { "field" : "categories.raw" }}}, "size": 0}

I also used the following aggregated query, with the same results as the above aggregated:

{"query": {"multi_match": {"query": "whatever","fields": ["name^5","company","description"]}},"aggs": {"categories": {"terms": {"field": "categories.raw"}}},"size": 0}

What I'd like to get is the aggregate of the categories field with the same results as the ones obtained by the search of documents.
Not sure what I'm missing, but I would expect that the same search gives the same results for an aggregation.

Any ideas?

Thanks,
Isaac

Found the issue, I placed the size value outside of the terms field.
Once I placed within the terms field, it started working fine.

2 Likes